org.apache.bookkeeper.proto.BookieServer Java Examples

The following examples show how to use org.apache.bookkeeper.proto.BookieServer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZKTestEnv.java    From herddb with Apache License 2.0 6 votes vote down vote up
public void startStoppedBookie(String addr) throws Exception {
    int index = 0;
    for (BookieServer bookie : bookies) {
        if (bookie.getLocalAddress().getSocketAddress().toString().equals(addr)) {
            if (bookie.isRunning()) {
                throw new Exception("you did not stop bookie " + addr);
            }
            ServerConfiguration conf = createBookieConf(bookie.getLocalAddress().getPort());
            BookieServer newBookie = new BookieServer(conf);
            bookies.set(index, newBookie);
            newBookie.start();
            return;
        }
        index++;
    }
    throw new Exception("Cannot find bookie " + addr);
}
 
Example #2
Source File: TestBookKeeperSpeculativeRead.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Sleep a bookie until I count down the latch
 *
 * @param latch
 *          latch to wait on
 * @param bookie
 *          bookie server
 * @throws Exception
 */
private void sleepBookie(final CountDownLatch latch, final BookieServer bookie)
    throws Exception {

  Thread sleeper = new Thread() {
    public void run() {
      try {
        bookie.suspendProcessing();
        latch.await(2, TimeUnit.MINUTES);
        bookie.resumeProcessing();
      } catch (Exception e) {
        LOG.error("Error suspending bookie", e);
      }
    }
  };
  sleeper.setName("BookieServerSleeper-" + bookie.getBookie().getId());
  sleeper.start();
}
 
Example #3
Source File: TestBookKeeperJournalManager.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Sleep a bookie until I count down the latch
 *
 * @param latch
 *          Latch to wait on
 * @param bookie
 *          bookie server
 * @throws Exception
 */
private void sleepBookie(final CountDownLatch l, final BookieServer bookie)
    throws Exception {

  Thread sleeper = new Thread() {
    public void run() {
      try {
        bookie.suspendProcessing();
        l.await(60, TimeUnit.SECONDS);
        bookie.resumeProcessing();
      } catch (Exception e) {
        LOG.error("Error suspending bookie", e);
      }
    }
  };
  sleeper.setName("BookieServerSleeper-" + bookie.getBookie().getId());
  sleeper.start();
}
 
Example #4
Source File: LocalBookkeeperEnsemble.java    From pulsar with Apache License 2.0 6 votes vote down vote up
public void startBK() throws Exception {
    for (int i = 0; i < numberOfBookies; i++) {

        try {
            bs[i] = new BookieServer(bsConfs[i], NullStatsLogger.INSTANCE);
        } catch (InvalidCookieException e) {
            // InvalidCookieException can happen if the machine IP has changed
            // Since we are running here a local bookie that is always accessed
            // from localhost, we can ignore the error
            for (String path : zkc.getChildren("/ledgers/cookies", false)) {
                zkc.delete("/ledgers/cookies/" + path, -1);
            }

            // Also clean the on-disk cookie
            new File(new File(bsConfs[i].getJournalDirNames()[0], "current"), "VERSION").delete();

            // Retry to start the bookie after cleaning the old left cookie
            bs[i] = new BookieServer(bsConfs[i], NullStatsLogger.INSTANCE);

        }
        bs[i].start();
    }
}
 
Example #5
Source File: BKJMUtil.java    From big-c with Apache License 2.0 6 votes vote down vote up
BookieServer newBookie() throws Exception {
  int port = nextPort++;
  ServerConfiguration bookieConf = new ServerConfiguration();
  bookieConf.setBookiePort(port);
  File tmpdir = File.createTempFile("bookie" + Integer.toString(port) + "_",
                                    "test");
  tmpdir.delete();
  tmpdir.mkdir();

  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;
}
 
Example #6
Source File: LocalBookkeeperEnsemble.java    From pulsar with Apache License 2.0 6 votes vote down vote up
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");
}
 
Example #7
Source File: BookKeeperClusterTestCase.java    From pulsar with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #8
Source File: BookKeeperClusterTestCase.java    From pulsar with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: BookKeeperServiceRunner.java    From pravega with Apache License 2.0 6 votes vote down vote up
@Override
public void close() throws Exception {
    try {
        this.servers.stream().filter(Objects::nonNull).forEach(BookieServer::shutdown);
        if (this.zkServer.get() != null) {
            this.zkServer.get().close();
        }
    } finally {
        cleanupDirectories();
    }

    Thread c = this.cleanup.getAndSet(null);
    if (c != null) {
        Runtime.getRuntime().removeShutdownHook(c);
    }
}
 
Example #10
Source File: BookKeeperClusterTestCase.java    From pulsar with Apache License 2.0 6 votes vote down vote up
/**
 * Sleep a bookie
 *
 * @param addr
 *            Socket Address
 * @param seconds
 *            Sleep seconds
 * @return Count Down latch which will be counted down when sleep finishes
 * @throws InterruptedException
 * @throws IOException
 */
public CountDownLatch sleepBookie(InetSocketAddress addr, final int seconds) throws Exception {
    for (final BookieServer bookie : bs) {
        if (bookie.getLocalAddress().equals(addr)) {
            final CountDownLatch l = new CountDownLatch(1);
            Thread sleeper = new Thread() {
                @Override
                public void run() {
                    try {
                        bookie.suspendProcessing();
                        l.countDown();
                        Thread.sleep(seconds * 1000);
                        bookie.resumeProcessing();
                    } catch (Exception e) {
                        LOG.error("Error suspending bookie", e);
                    }
                }
            };
            sleeper.start();
            return l;
        }
    }
    throw new IOException("Bookie not found");
}
 
Example #11
Source File: ZKTestEnv.java    From herddb with Apache License 2.0 6 votes vote down vote up
private String startBookie(boolean format) throws Exception {
    if (format && !bookies.isEmpty()) {
        throw new Exception("cannot format, you aleady have bookies");
    }
    ServerConfiguration conf = createBookieConf(nextBookiePort++);

    if (format) {
        BookKeeperAdmin.initNewCluster(conf);
        BookKeeperAdmin.format(conf, false, true);
    }

    BookieServer bookie = new BookieServer(conf);
    bookies.add(bookie);
    bookie.start();
    return bookie.getLocalAddress().getSocketAddress().toString();
}
 
Example #12
Source File: BookKeeperClusterTestCase.java    From pulsar with Apache License 2.0 6 votes vote down vote up
/**
 * Sleep a bookie until I count down the latch
 *
 * @param addr
 *            Socket Address
 * @param latch
 *            Latch to wait on
 * @throws InterruptedException
 * @throws IOException
 */
public void sleepBookie(InetSocketAddress addr, final CountDownLatch l) throws Exception {
    for (final BookieServer bookie : bs) {
        if (bookie.getLocalAddress().equals(addr)) {
            Thread sleeper = new Thread() {
                @Override
                public void run() {
                    try {
                        bookie.suspendProcessing();
                        l.await();
                        bookie.resumeProcessing();
                    } catch (Exception e) {
                        LOG.error("Error suspending bookie", e);
                    }
                }
            };
            sleeper.start();
            return;
        }
    }
    throw new IOException("Bookie not found");
}
 
Example #13
Source File: TestBookKeeperJournalManager.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Sleep a bookie until I count down the latch
 *
 * @param latch
 *          Latch to wait on
 * @param bookie
 *          bookie server
 * @throws Exception
 */
private void sleepBookie(final CountDownLatch l, final BookieServer bookie)
    throws Exception {

  Thread sleeper = new Thread() {
    public void run() {
      try {
        bookie.suspendProcessing();
        l.await(60, TimeUnit.SECONDS);
        bookie.resumeProcessing();
      } catch (Exception e) {
        LOG.error("Error suspending bookie", e);
      }
    }
  };
  sleeper.setName("BookieServerSleeper-" + bookie.getBookie().getId());
  sleeper.start();
}
 
Example #14
Source File: TestBookKeeperSpeculativeRead.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Sleep a bookie until I count down the latch
 *
 * @param latch
 *          latch to wait on
 * @param bookie
 *          bookie server
 * @throws Exception
 */
private void sleepBookie(final CountDownLatch latch, final BookieServer bookie)
    throws Exception {

  Thread sleeper = new Thread() {
    public void run() {
      try {
        bookie.suspendProcessing();
        latch.await(2, TimeUnit.MINUTES);
        bookie.resumeProcessing();
      } catch (Exception e) {
        LOG.error("Error suspending bookie", e);
      }
    }
  };
  sleeper.setName("BookieServerSleeper-" + bookie.getBookie().getId());
  sleeper.start();
}
 
Example #15
Source File: BookKeeperClusterTestCase.java    From pulsar with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #16
Source File: BookKeeperClusterTestCase.java    From pulsar with Apache License 2.0 6 votes vote down vote up
/**
 * 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, String ledgerRootPath) 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(ledgerRootPath + "/available/" + InetAddress.getLocalHost().getHostAddress() + ":" + port,
            false) == null) {
        Thread.sleep(500);
    }

    bkc.readBookiesBlocking();
    LOG.info("New bookie on port " + port + " has been created.");

    return server;
}
 
Example #17
Source File: BKJMUtil.java    From hadoop with Apache License 2.0 6 votes vote down vote up
BookieServer newBookie() throws Exception {
  int port = nextPort++;
  ServerConfiguration bookieConf = new ServerConfiguration();
  bookieConf.setBookiePort(port);
  File tmpdir = File.createTempFile("bookie" + Integer.toString(port) + "_",
                                    "test");
  tmpdir.delete();
  tmpdir.mkdir();

  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;
}
 
Example #18
Source File: BookKeeperClusterTestCase.java    From pulsar with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #19
Source File: RackAwareTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@BeforeClass
protected void setup() throws Exception {
    super.setup();

    // Start bookies with specific racks
    for (int i = 0; i < NUM_BOOKIES; i++) {
        File bkDataDir = Files.createTempDirectory("bk" + Integer.toString(i) + "test").toFile();
        ServerConfiguration conf = new ServerConfiguration();

        conf.setBookiePort(0);
        conf.setZkServers("127.0.0.1:" + bkEnsemble.getZookeeperPort());
        conf.setJournalDirName(bkDataDir.getPath());
        conf.setLedgerDirNames(new String[] { bkDataDir.getPath() });
        conf.setAllowLoopback(true);

        // Use different advertised addresses for each bookie, so we can place them in different
        // racks.
        // Eg: 1st bookie will be 10.0.0.1, 2nd 10.0.0.2 and so on
        String addr = String.format("10.0.0.%d", i + 1);
        conf.setAdvertisedAddress(addr);

        BookieServer bs = new BookieServer(conf, NullStatsLogger.INSTANCE);

        bs.start();
        bookies.add(bs);
    }

}
 
Example #20
Source File: RackAwareTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@AfterClass
protected void shutdown() throws Exception {
    super.shutdown();

    for (BookieServer bs : bookies) {
        bs.shutdown();
    }

    bookies.clear();
}
 
Example #21
Source File: BookKeeperClusterTestCase.java    From pulsar with Apache License 2.0 5 votes vote down vote up
/**
 * Will stops all the auto recovery processes for the bookie cluster, if isAutoRecoveryEnabled is true.
 */
public void stopReplicationService() throws Exception {
    if (false == isAutoRecoveryEnabled()) {
        return;
    }
    for (Entry<BookieServer, AutoRecoveryMain> autoRecoveryProcess : autoRecoveryProcesses.entrySet()) {
        autoRecoveryProcess.getValue().shutdown();
        LOG.debug("Shutdown Auditor Recovery for the bookie:" + autoRecoveryProcess.getKey().getLocalAddress());
    }
}
 
Example #22
Source File: BookKeeperClusterTestCase.java    From pulsar with Apache License 2.0 5 votes vote down vote up
private void stopAutoRecoveryService(BookieServer toRemove) throws Exception {
    AutoRecoveryMain autoRecoveryMain = autoRecoveryProcesses.remove(toRemove);
    if (null != autoRecoveryMain && isAutoRecoveryEnabled()) {
        autoRecoveryMain.shutdown();
        LOG.debug("Shutdown auto recovery for bookieserver:" + toRemove.getLocalAddress());
    }
}
 
Example #23
Source File: BookKeeperServiceRunner.java    From pravega with Apache License 2.0 5 votes vote down vote up
private BookieServer runBookie(int bkPort) throws Exception {
    // Attempt to reuse an existing data directory. This is useful in case of stops & restarts, when we want to preserve
    // already committed data.
    File journalDir = this.journalDirs.getOrDefault(bkPort, null);
    if (journalDir == null) {
        journalDir = IOUtils.createTempDir("bookiejournal_" + bkPort, "_test");
        log.info("Journal Dir[{}]: {}.", bkPort, journalDir.getPath());
        this.journalDirs.put(bkPort, journalDir);
        setupTempDir(journalDir);
    }

    File ledgerDir = this.ledgerDirs.getOrDefault(bkPort, null);
    if (ledgerDir == null) {
        ledgerDir = Strings.isNullOrEmpty(this.ledgersDir) ? null : new File(this.ledgersDir);
        ledgerDir = IOUtils.createTempDir("bookieledger_" + bkPort, "_test", ledgerDir);
        log.info("Ledgers Dir[{}]: {}.", bkPort, ledgerDir.getPath());
        this.ledgerDirs.put(bkPort, ledgerDir);
        setupTempDir(ledgerDir);
    }

    val conf = new ServerConfiguration();
    conf.setBookiePort(bkPort);
    conf.setMetadataServiceUri("zk://" + LOOPBACK_ADDRESS.getHostAddress() + ":" + this.zkPort + ledgersPath);
    conf.setJournalDirName(journalDir.getPath());
    conf.setLedgerDirNames(new String[]{ledgerDir.getPath()});
    conf.setAllowLoopback(true);
    conf.setJournalAdaptiveGroupWrites(true);

    if (secureBK) {
        conf.setTLSProvider("OpenSSL");
        conf.setTLSProviderFactoryClass("org.apache.bookkeeper.tls.TLSContextFactory");
        conf.setTLSKeyStore(this.tLSKeyStore);
        conf.setTLSKeyStorePasswordPath(this.tLSKeyStorePasswordPath);
    }

    log.info("Starting Bookie at port " + bkPort);
    val bs = new BookieServer(conf);
    bs.start();
    return bs;
}
 
Example #24
Source File: LocalDLMEmulator.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #25
Source File: TestBookKeeperSpeculativeRead.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void teardownBookkeeper() throws Exception {
  bkutil.teardown();
  for (BookieServer bk : bks) {
    bk.shutdown();
  }
}
 
Example #26
Source File: TestBookKeeperSpeculativeRead.java    From big-c with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void teardownBookkeeper() throws Exception {
  bkutil.teardown();
  for (BookieServer bk : bks) {
    bk.shutdown();
  }
}
 
Example #27
Source File: ZKTestEnv.java    From herddb with Apache License 2.0 5 votes vote down vote up
public void pauseBookie(String addr) throws Exception {
    for (BookieServer bookie : bookies) {
        if (bookie.getLocalAddress().getSocketAddress().toString().equals(addr)) {
            bookie.suspendProcessing();
            return;
        }
    }
    throw new Exception("Cannot find bookie " + addr);
}
 
Example #28
Source File: ZKTestEnv.java    From herddb with Apache License 2.0 5 votes vote down vote up
public void stopBookie(String addr) throws Exception {
    for (BookieServer bookie : bookies) {
        if (bookie.getLocalAddress().getSocketAddress().toString().equals(addr)) {
            bookie.shutdown();
            bookie.join();
            return;
        }
    }
    throw new Exception("Cannot find bookie " + addr);
}
 
Example #29
Source File: ZKTestEnv.java    From herddb with Apache License 2.0 5 votes vote down vote up
public void resumeBookie(String addr) throws Exception {
    for (BookieServer bookie : bookies) {
        if (bookie.getLocalAddress().getSocketAddress().toString().equals(addr)) {
            bookie.resumeProcessing();
            return;
        }
    }
    throw new Exception("Cannot find bookie " + addr);
}
 
Example #30
Source File: KafkaBrokerStarter.java    From kop with Apache License 2.0 4 votes vote down vote up
BrokerStarter(String[] args) throws Exception {
    StarterArguments starterArguments = new StarterArguments();
    JCommander jcommander = new JCommander(starterArguments);
    jcommander.setProgramName("KafkaBrokerStarter");

    // parse args by JCommander
    jcommander.parse(args);
    if (starterArguments.help) {
        jcommander.usage();
        Runtime.getRuntime().exit(-1);
    }

    // init broker config
    if (isBlank(starterArguments.brokerConfigFile)) {
        jcommander.usage();
        throw new IllegalArgumentException("Need to specify a configuration file for kafkaBroker");
    } else {
        brokerConfig = loadConfig(starterArguments.brokerConfigFile);
    }

    int maxFrameSize = brokerConfig.getMaxMessageSize() + Commands.MESSAGE_SIZE_FRAME_PADDING;
    if (maxFrameSize >= DirectMemoryUtils.maxDirectMemory()) {
        throw new IllegalArgumentException("Max message size need smaller than jvm directMemory");
    }


    if (brokerConfig.getAdvertisedAddress() != null
        && !brokerConfig.getListeners().contains(brokerConfig.getAdvertisedAddress())) {
        String err = "Error config: advertisedAddress - " + brokerConfig.getAdvertisedAddress()
            + " and listeners - " + brokerConfig.getListeners() + " not match.";
        log.error(err);
        throw new IllegalArgumentException(err);
    }

    // init kafka broker service
    kafkaService = new KafkaService(brokerConfig);

    // if no argument to run bookie in cmd line, read from pulsar config
    if (!argsContains(args, "-rb") && !argsContains(args, "--run-bookie")) {
        checkState(!starterArguments.runBookie,
            "runBookie should be false if has no argument specified");
        starterArguments.runBookie = brokerConfig.isEnableRunBookieTogether();
    }
    if (!argsContains(args, "-ra") && !argsContains(args, "--run-bookie-autorecovery")) {
        checkState(!starterArguments.runBookieAutoRecovery,
            "runBookieAutoRecovery should be false if has no argument specified");
        starterArguments.runBookieAutoRecovery = brokerConfig.isEnableRunBookieAutoRecoveryTogether();
    }

    if ((starterArguments.runBookie || starterArguments.runBookieAutoRecovery)
        && isBlank(starterArguments.bookieConfigFile)) {
        jcommander.usage();
        throw new IllegalArgumentException("No configuration file for Bookie");
    }

    // init stats provider
    if (starterArguments.runBookie || starterArguments.runBookieAutoRecovery) {
        checkState(isNotBlank(starterArguments.bookieConfigFile),
            "No configuration file for Bookie");
        bookieConfig = readBookieConfFile(starterArguments.bookieConfigFile);
        Class<? extends StatsProvider> statsProviderClass = bookieConfig.getStatsProviderClass();
        bookieStatsProvider = ReflectionUtils.newInstance(statsProviderClass);
    } else {
        bookieConfig = null;
        bookieStatsProvider = null;
    }

    // init bookie server
    if (starterArguments.runBookie) {
        checkNotNull(bookieConfig, "No ServerConfiguration for Bookie");
        checkNotNull(bookieStatsProvider, "No Stats Provider for Bookie");
        bookieServer = new BookieServer(bookieConfig, bookieStatsProvider.getStatsLogger(""));
    } else {
        bookieServer = null;
    }

    // init bookie AutorecoveryMain
    if (starterArguments.runBookieAutoRecovery) {
        checkNotNull(bookieConfig, "No ServerConfiguration for Bookie Autorecovery");
        autoRecoveryMain = new AutoRecoveryMain(bookieConfig);
    } else {
        autoRecoveryMain = null;
    }
}