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

The following examples show how to use org.apache.bookkeeper.conf.ServerConfiguration#setUseHostNameAsBookieID() . 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
private ServerConfiguration createBookieConf(int port) {
    ServerConfiguration conf = new ServerConfiguration();
    conf.setBookiePort(port++);
    LOG.log(Level.INFO, "STARTING BOOKIE at port {0}", String.valueOf(port));
    conf.setUseHostNameAsBookieID(true);
    // no need to preallocate journal and entrylog in tests
    conf.setEntryLogFilePreAllocationEnabled(false);
    conf.setProperty("journalPreAllocSizeMB", 1);
    Path targetDir = path.resolve("bookie_data_" + conf.getBookiePort());
    conf.setMetadataServiceUri("zk+null://" + zkServer.getConnectString() + herddb.server.ServerConfiguration.PROPERTY_BOOKKEEPER_LEDGERS_PATH_DEFAULT);
    conf.setLedgerDirNames(new String[]{targetDir.toAbsolutePath().toString()});
    conf.setJournalDirName(targetDir.toAbsolutePath().toString());
    conf.setFlushInterval(10000);
    conf.setGcWaitTime(5);
    conf.setJournalFlushWhenQueueEmpty(true);
    //        conf.setJournalBufferedEntriesThreshold(1);
    conf.setAutoRecoveryDaemonEnabled(false);
    // no need for real network in tests
    conf.setEnableLocalTransport(true);
    conf.setDisableServerSocketBind(true);
    // no need to fsync in tests
    conf.setJournalSyncData(false);
    conf.setAllowLoopback(true);
    conf.setProperty("journalMaxGroupWaitMSec", 10); // default 200ms
    return conf;
}
 
Example 2
Source File: ZKTestEnv.java    From herddb with Apache License 2.0 4 votes vote down vote up
public void startBookie(boolean format) throws Exception {
        if (bookie != null) {
            throw new Exception("bookie already started");
        }
        ServerConfiguration conf = new ServerConfiguration();
        conf.setBookiePort(0);
        conf.setUseHostNameAsBookieID(true);

        Path targetDir = path.resolve("bookie_data");
        conf.setZkServers("localhost:1282");
        conf.setZkLedgersRootPath("/ledgers");
        conf.setLedgerDirNames(new String[]{targetDir.toAbsolutePath().toString()});
        conf.setJournalDirName(targetDir.toAbsolutePath().toString());
        conf.setFlushInterval(10000);
        conf.setGcWaitTime(5);
        conf.setJournalFlushWhenQueueEmpty(true);
//        conf.setJournalBufferedEntriesThreshold(1);
        conf.setAutoRecoveryDaemonEnabled(false);
        conf.setEnableLocalTransport(true);
        conf.setJournalSyncData(false);

        conf.setAllowLoopback(true);
        conf.setProperty("journalMaxGroupWaitMSec", 10); // default 200ms

        try (ZooKeeperClient zkc = ZooKeeperClient
                .newBuilder()
                .connectString("localhost:1282")
                .sessionTimeoutMs(10000)
                .build()) {

            boolean rootExists = zkc.exists(getPath(), false) != null;

            if (!rootExists) {
                zkc.create(getPath(), new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
            }

        }

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

        this.bookie = new BookieServer(conf);
        this.bookie.start();
    }