Search in sources :

Example 6 with ServerConfiguration

use of org.apache.bookkeeper.conf.ServerConfiguration in project distributedlog by twitter.

the class DLMTestUtil method loadTestBkConf.

public static ServerConfiguration loadTestBkConf() {
    ServerConfiguration conf = new ServerConfiguration();
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    URL confUrl = classLoader.getResource("bk_server.conf");
    try {
        if (null != confUrl) {
            conf.loadConf(confUrl);
            LOG.info("loaded bk_server.conf from resources");
        }
    } catch (org.apache.commons.configuration.ConfigurationException ex) {
        LOG.warn("loading conf failed", ex);
    }
    conf.setAllowLoopback(true);
    return conf;
}
Also used : ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) URL(java.net.URL)

Example 7 with ServerConfiguration

use of org.apache.bookkeeper.conf.ServerConfiguration in project distributedlog by twitter.

the class LocalDLMEmulator method newBookie.

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;
}
Also used : ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) BookieServer(org.apache.bookkeeper.proto.BookieServer) IOException(java.io.IOException) File(java.io.File)

Example 8 with ServerConfiguration

use of org.apache.bookkeeper.conf.ServerConfiguration in project pulsar by yahoo.

the class BookKeeperClusterTestCase method restartBookies.

/**
     * 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);
    }
}
Also used : ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) BookieServer(org.apache.bookkeeper.proto.BookieServer) ArrayList(java.util.ArrayList)

Example 9 with ServerConfiguration

use of org.apache.bookkeeper.conf.ServerConfiguration in project pravega by pravega.

the class BookKeeperServiceRunner method runBookie.

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 perserve
    // already committed data.
    File tmpDir = this.tempDirs.getOrDefault(bkPort, null);
    if (tmpDir == null) {
        tmpDir = IOUtils.createTempDir("bookie_" + bkPort, "test");
        tmpDir.deleteOnExit();
        this.tempDirs.put(bkPort, tmpDir);
        log.info("Created " + tmpDir);
        if (!tmpDir.delete() || !tmpDir.mkdir()) {
            throw new IOException("Couldn't create bookie dir " + tmpDir);
        }
    }
    val conf = new ServerConfiguration();
    conf.setBookiePort(bkPort);
    conf.setZkServers(LOOPBACK_ADDRESS.getHostAddress() + ":" + this.zkPort);
    conf.setJournalDirName(tmpDir.getPath());
    conf.setLedgerDirNames(new String[] { tmpDir.getPath() });
    conf.setAllowLoopback(true);
    conf.setJournalAdaptiveGroupWrites(false);
    conf.setZkLedgersRootPath(ledgersPath);
    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;
}
Also used : lombok.val(lombok.val) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) BookieServer(org.apache.bookkeeper.proto.BookieServer) IOException(java.io.IOException) File(java.io.File)

Aggregations

ServerConfiguration (org.apache.bookkeeper.conf.ServerConfiguration)9 BookieServer (org.apache.bookkeeper.proto.BookieServer)5 File (java.io.File)3 IOException (java.io.IOException)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 lombok.val (lombok.val)1 DataSketchesMetricsProvider (org.apache.bokkeeper.stats.datasketches.DataSketchesMetricsProvider)1 DbLedgerStorage (org.apache.bookkeeper.bookie.storage.ldb.DbLedgerStorage)1 NullStatsLogger (org.apache.bookkeeper.stats.NullStatsLogger)1 StatsLogger (org.apache.bookkeeper.stats.StatsLogger)1