Java Code Examples for org.apache.bookkeeper.conf.ServerConfiguration#setProperty()
The following examples show how to use
org.apache.bookkeeper.conf.ServerConfiguration#setProperty() .
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 |
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: BookKeeperClusterTestCase.java From pulsar with Apache License 2.0 | 6 votes |
protected ServerConfiguration newServerConfiguration(int port, String zkServers, File journalDir, File[] ledgerDirs, String ledgerRootPath) { ServerConfiguration conf = new ServerConfiguration(baseConf); conf.setBookiePort(port); if (ledgerRootPath != "") { conf.setMetadataServiceUri("zk://" + zkUtil.getZooKeeperConnectString() + ledgerRootPath); }else { conf.setZkServers(zkServers); } conf.setJournalDirName(journalDir.getPath()); conf.setAllowLoopback(true); conf.setFlushInterval(60 * 1000); conf.setGcWaitTime(60 * 1000); conf.setAllocatorPoolingPolicy(PoolingPolicy.UnpooledHeap); 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"); conf.setProperty(DbLedgerStorage.WRITE_CACHE_MAX_SIZE_MB, 4); conf.setProperty(DbLedgerStorage.READ_AHEAD_CACHE_MAX_SIZE_MB, 4); return conf; }
Example 3
Source File: LocalBookkeeperEnsemble.java From pulsar with Apache License 2.0 | 5 votes |
public void start(boolean enableStreamStorage) throws Exception { LOG.debug("Local ZK/BK starting ..."); ServerConfiguration conf = new ServerConfiguration(); // Use minimal configuration requiring less memory for unit tests conf.setLedgerStorageClass(DbLedgerStorage.class.getName()); conf.setProperty("dbStorage_writeCacheMaxSizeMb", 2); conf.setProperty("dbStorage_readAheadCacheMaxSizeMb", 1); conf.setProperty("dbStorage_rocksDB_writeBufferSizeMB", 1); conf.setProperty("dbStorage_rocksDB_blockCacheSize", 1024 * 1024); conf.setFlushInterval(60000); conf.setJournalSyncData(false); conf.setProperty("journalMaxGroupWaitMSec", 0L); conf.setAllowLoopback(true); conf.setGcWaitTime(60000); conf.setNumAddWorkerThreads(0); conf.setNumReadWorkerThreads(0); conf.setNumHighPriorityWorkerThreads(0); conf.setNumJournalCallbackThreads(0); conf.setServerNumIOThreads(1); conf.setNumLongPollWorkerThreads(1); conf.setAllocatorPoolingPolicy(PoolingPolicy.UnpooledHeap); runZookeeper(1000); initializeZookeper(); runBookies(conf); if (enableStreamStorage) { runStreamStorage(new CompositeConfiguration()); } }
Example 4
Source File: ZKTestEnv.java From herddb with Apache License 2.0 | 4 votes |
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(); }