Java Code Examples for org.apache.bookkeeper.conf.ServerConfiguration#getBookiePort()

The following examples show how to use org.apache.bookkeeper.conf.ServerConfiguration#getBookiePort() . 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: 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 2
Source File: BookKeeperClusterTestCase.java    From pulsar with Apache License 2.0 3 votes vote down vote up
/**
 * Helper method to startup a new bookie server with the indicated port number. Also, starts the auto recovery
 * process, if the isAutoRecoveryEnabled is set true.
 *
 * @param port
 *            Port to start the new bookie server on
 * @throws IOException
 */
public int startNewBookie() throws Exception {
    ServerConfiguration conf = newServerConfiguration();
    startBookie(conf);

    return conf.getBookiePort();
}