sijie closed pull request #2480: Allow to configure bookie settings when 
running in standalone mode
URL: https://github.com/apache/incubator-pulsar/pull/2480
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/conf/standalone.conf b/conf/standalone.conf
index 09d369c6ff..b09fcd6fd1 100644
--- a/conf/standalone.conf
+++ b/conf/standalone.conf
@@ -420,3 +420,82 @@ exposePublisherStats=true
 # Deprecated. Use configurationStoreServers
 globalZookeeperServers=
 
+
+### --- BookKeeper Configuration --- #####
+
+ledgerStorageClass=org.apache.bookkeeper.bookie.storage.ldb.DbLedgerStorage
+
+# Size of Write Cache. Memory is allocated from JVM direct memory.
+# Write cache is used to buffer entries before flushing into the entry log
+# For good performance, it should be big enough to hold a sub
+dbStorage_writeCacheMaxSizeMb=256
+
+# Size of Read cache. Memory is allocated from JVM direct memory.
+# This read cache is pre-filled doing read-ahead whenever a cache miss happens
+dbStorage_readAheadCacheMaxSizeMb=64
+
+# How many entries to pre-fill in cache after a read cache miss
+dbStorage_readAheadCacheBatchSize=1000
+
+flushInterval=60000
+
+## RocksDB specific configurations
+## DbLedgerStorage uses RocksDB to store the indexes from
+## (ledgerId, entryId) -> (entryLog, offset)
+
+# Size of RocksDB block-cache. For best performance, this cache
+# should be big enough to hold a significant portion of the index
+# database which can reach ~2GB in some cases
+# Default is 16 MBytes
+dbStorage_rocksDB_blockCacheSize=16777216
+
+# Other RocksDB specific tunables
+dbStorage_rocksDB_writeBufferSizeMB=4
+dbStorage_rocksDB_sstSizeInMB=4
+dbStorage_rocksDB_blockSize=4096
+dbStorage_rocksDB_bloomFilterBitsPerKey=10
+dbStorage_rocksDB_numLevels=-1
+dbStorage_rocksDB_numFilesInLevel0=4
+dbStorage_rocksDB_maxSizeInLevel1MB=256
+
+# Maximum latency to impose on a journal write to achieve grouping
+journalMaxGroupWaitMSec=1
+
+# Should the data be fsynced on journal before acknowledgment.
+journalSyncData=false
+
+
+# For each ledger dir, maximum disk space which can be used.
+# Default is 0.95f. i.e. 95% of disk can be used at most after which nothing 
will
+# be written to that partition. If all ledger dir partions are full, then 
bookie
+# will turn to readonly mode if 'readOnlyModeEnabled=true' is set, else it will
+# shutdown.
+# Valid values should be in between 0 and 1 (exclusive).
+diskUsageThreshold=0.99
+
+# The disk free space low water mark threshold.
+# Disk is considered full when usage threshold is exceeded.
+# Disk returns back to non-full state when usage is below low water mark 
threshold.
+# This prevents it from going back and forth between these states frequently
+# when concurrent writes and compaction are happening. This also prevent 
bookie from
+# switching frequently between read-only and read-writes states in the same 
cases.
+diskUsageWarnThreshold=0.99
+
+# Whether the bookie allowed to use a loopback interface as its primary
+# interface(i.e. the interface it uses to establish its identity)?
+# By default, loopback interfaces are not allowed as the primary
+# interface.
+# Using a loopback interface as the primary interface usually indicates
+# a configuration error. For example, its fairly common in some VPS setups
+# to not configure a hostname, or to have the hostname resolve to
+# 127.0.0.1. If this is the case, then all bookies in the cluster will
+# establish their identities as 127.0.0.1:3181, and only one will be able
+# to join the cluster. For VPSs configured like this, you should explicitly
+# set the listening interface.
+allowLoopback=true
+
+# How long the interval to trigger next garbage collection, in milliseconds
+# Since garbage collection is running in background, too frequent gc
+# will heart performance. It is better to give a higher number of gc
+# interval if there is enough disk capacity.
+gcWaitTime=300000
diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandalone.java 
b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandalone.java
index cf07d8c8ba..0e2043d1a9 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandalone.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandalone.java
@@ -21,6 +21,9 @@
 import com.beust.jcommander.Parameter;
 import com.ea.agentloader.AgentLoader;
 import com.google.common.collect.Sets;
+
+import org.apache.bookkeeper.conf.ServerConfiguration;
+import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.pulsar.broker.PulsarService;
 import org.apache.pulsar.broker.ServiceConfiguration;
 import org.apache.pulsar.broker.ServiceConfigurationUtils;
@@ -36,6 +39,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
 import java.net.URL;
 import java.nio.file.Paths;
 import java.util.Optional;
@@ -251,11 +255,14 @@ void start() throws Exception {
         AgentLoader.loadAgentClass(Agent.class.getName(), null);
 
         if (!this.isOnlyBroker()) {
+            ServerConfiguration bkServerConf = new ServerConfiguration();
+            bkServerConf.loadConf(new File(configFile).toURI().toURL());
+
             // Start LocalBookKeeper
             bkEnsemble = new LocalBookkeeperEnsemble(
                     this.getNumOfBk(), this.getZkPort(), this.getBkPort(), 
this.getStreamStoragePort(), this.getZkDir(),
                     this.getBkDir(), this.isWipeData(), "127.0.0.1");
-            bkEnsemble.startStandalone(!this.isNoStreamStorage());
+            bkEnsemble.startStandalone(bkServerConf, 
!this.isNoStreamStorage());
         }
 
         if (this.isNoBroker()) {
diff --git 
a/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
 
b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
index 94cd32582d..039a8a277b 100644
--- 
a/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
+++ 
b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
@@ -45,7 +45,6 @@
 import org.apache.bookkeeper.clients.StorageClientBuilder;
 import org.apache.bookkeeper.clients.admin.StorageAdminClient;
 import org.apache.bookkeeper.clients.config.StorageClientSettings;
-import org.apache.bookkeeper.clients.exceptions.ClientException;
 import org.apache.bookkeeper.clients.exceptions.NamespaceExistsException;
 import org.apache.bookkeeper.clients.exceptions.NamespaceNotFoundException;
 import org.apache.bookkeeper.common.concurrent.FutureUtils;
@@ -62,7 +61,6 @@
 import org.apache.bookkeeper.stream.storage.impl.cluster.ZkClusterInitializer;
 import org.apache.bookkeeper.util.MathUtils;
 import org.apache.commons.configuration.CompositeConfiguration;
-import org.apache.pulsar.common.util.FutureUtil;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
@@ -228,8 +226,6 @@ private void runBookies(ServerConfiguration baseConf) 
throws Exception {
             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);
 
             try {
                 bs[i] = new BookieServer(bsConfs[i], NullStatsLogger.INSTANCE);
@@ -323,7 +319,10 @@ public void start() throws Exception {
         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);
 
         runZookeeper(1000);
         initializeZookeper();
@@ -331,22 +330,13 @@ public void start() throws Exception {
     }
 
     public void startStandalone() throws Exception {
-        startStandalone(false);
+        startStandalone(new ServerConfiguration(), false);
     }
 
-    public void startStandalone(boolean enableStreamStorage) throws Exception {
+    public void startStandalone(ServerConfiguration conf, boolean 
enableStreamStorage) 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_writeCacheMaxSizeMb", 256);
-        conf.setProperty("dbStorage_readAheadCacheMaxSizeMb", 64);
-        conf.setFlushInterval(60000);
-        conf.setProperty("journalMaxGroupWaitMSec", 1L);
         conf.setAdvertisedAddress(advertisedAddress);
-        // use high disk usage thresholds for standalone
-        conf.setDiskUsageWarnThreshold(0.9999f);
-        conf.setDiskUsageThreshold(0.99999f);
 
         runZookeeper(1000);
         initializeZookeper();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to