Search in sources :

Example 1 with ServerConfiguration

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

the class BookKeeperClusterTestCase method startBookie.

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

Example 2 with ServerConfiguration

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

the class BookKeeperClusterTestCase method startNewBookie.

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

Example 3 with ServerConfiguration

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

the class BookKeeperClusterTestCase method newServerConfiguration.

protected ServerConfiguration newServerConfiguration(int port, String zkServers, File journalDir, File[] ledgerDirs) {
    ServerConfiguration conf = new ServerConfiguration(baseConf);
    conf.setBookiePort(port);
    conf.setZkServers(zkServers);
    conf.setJournalDirName(journalDir.getPath());
    conf.setAllowLoopback(true);
    conf.setFlushInterval(60 * 1000);
    conf.setGcWaitTime(60 * 1000);
    String[] ledgerDirNames = new String[ledgerDirs.length];
    for (int i = 0; i < ledgerDirs.length; i++) {
        ledgerDirNames[i] = ledgerDirs[i].getPath();
    }
    conf.setLedgerDirNames(ledgerDirNames);
    conf.setLedgerStorageClass("org.apache.bookkeeper.bookie.storage.ldb.DbLedgerStorage");
    return conf;
}
Also used : ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration)

Example 4 with ServerConfiguration

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

the class LocalBookkeeperEnsemble method runBookies.

private void runBookies(ServerConfiguration baseConf) throws Exception {
    LOG.info("Starting Bookie(s)");
    // Create Bookie Servers (B1, B2, B3)
    bs = new BookieServer[numberOfBookies];
    bsConfs = new ServerConfiguration[numberOfBookies];
    statsProviders = new StatsProvider[numberOfBookies];
    for (int i = 0; i < numberOfBookies; i++) {
        File bkDataDir = isNotBlank(bkDataDirName) ? Files.createDirectories(Paths.get(bkDataDirName + Integer.toString(i))).toFile() : Files.createTempDirectory("bk" + Integer.toString(i) + "test").toFile();
        if (this.clearOldData) {
            cleanDirectory(bkDataDir);
        }
        bsConfs[i] = new ServerConfiguration(baseConf);
        // override settings
        bsConfs[i].setBookiePort(initialPort + i);
        bsConfs[i].setZkServers("127.0.0.1:" + ZooKeeperDefaultPort);
        bsConfs[i].setJournalDirName(bkDataDir.getPath());
        bsConfs[i].setLedgerDirNames(new String[] { bkDataDir.getPath() });
        bsConfs[i].setAllowLoopback(true);
        bsConfs[i].setGcWaitTime(60000);
        String statsFilePath = FileSystems.getDefault().getPath(bkDataDir.getAbsolutePath(), "bookie-stats.json").toString();
        // Initialize Stats Provider
        statsProviders[i] = new DataSketchesMetricsProvider();
        bsConfs[i].setProperty("dataSketchesMetricsJsonFileReporter", statsFilePath);
        statsProviders[i].start(bsConfs[i]);
        StatsLogger statsLogger = statsProviders[i].getStatsLogger("");
        bs[i] = new BookieServer(bsConfs[i], statsLogger);
        bs[i].start();
        LOG.debug("Local BK[{}] started (port: {}, data_directory: {})", i, initialPort + i, bkDataDir.getAbsolutePath());
    }
}
Also used : DataSketchesMetricsProvider(org.apache.bokkeeper.stats.datasketches.DataSketchesMetricsProvider) NullStatsLogger(org.apache.bookkeeper.stats.NullStatsLogger) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) BookieServer(org.apache.bookkeeper.proto.BookieServer) File(java.io.File)

Example 5 with ServerConfiguration

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

the class LocalBookkeeperEnsemble method start.

public void start() throws Exception {
    LOG.debug("Local ZK/BK starting ...");
    ServerConfiguration conf = new ServerConfiguration();
    conf.setLedgerManagerFactoryClassName("org.apache.bookkeeper.meta.HierarchicalLedgerManagerFactory");
    conf.setLedgerStorageClass(DbLedgerStorage.class.getName());
    conf.setProperty("dbStorage_rocksDBEnabled", true);
    conf.setProperty("dbStorage_writeCacheMaxSizeMb", 256);
    conf.setProperty("dbStorage_readAheadCacheMaxSizeMb", 64);
    conf.setFlushInterval(60000);
    conf.setProperty("journalMaxGroupWaitMSec", 1L);
    runZookeeper(1000);
    initializeZookeper();
    runBookies(conf);
}
Also used : ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) DbLedgerStorage(org.apache.bookkeeper.bookie.storage.ldb.DbLedgerStorage)

Aggregations

ServerConfiguration (org.apache.bookkeeper.conf.ServerConfiguration)8 BookieServer (org.apache.bookkeeper.proto.BookieServer)4 File (java.io.File)2 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)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