You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by fp...@apache.org on 2012/04/20 19:18:36 UTC

svn commit: r1328452 - in /zookeeper/bookkeeper/trunk: ./ bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ doc/

Author: fpj
Date: Fri Apr 20 17:18:36 2012
New Revision: 1328452

URL: http://svn.apache.org/viewvc?rev=1328452&view=rev
Log:
BOOKKEEPER-173: Uncontrolled number of threads in bookkeeper (sijie via fpj)


Added:
    zookeeper/bookkeeper/trunk/doc/bookieConfigParams.textile
Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
    zookeeper/bookkeeper/trunk/doc/bookkeeperConfig.textile
    zookeeper/bookkeeper/trunk/doc/bookkeeperConfigParams.textile
    zookeeper/bookkeeper/trunk/doc/index.textile

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1328452&r1=1328451&r2=1328452&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Fri Apr 20 17:18:36 2012
@@ -134,6 +134,8 @@ Trunk (unreleased changes)
 
         BOOKKEEPER-218: Provide journal manager to manage journal related operations (sijie)
 
+	BOOKKEEPER-173: Uncontrolled number of threads in bookkeeper (sijie via fpj)
+
       hedwig-server/
 
         BOOKKEEPER-77: Add a console client for hedwig (Sijie Guo via ivank)

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java?rev=1328452&r1=1328451&r2=1328452&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java Fri Apr 20 17:18:36 2012
@@ -78,10 +78,9 @@ public class BookKeeper {
     final BookieClient bookieClient;
     final BookieWatcher bookieWatcher;
 
-    OrderedSafeExecutor callbackWorker = new OrderedSafeExecutor(Runtime
-            .getRuntime().availableProcessors());
-    final OrderedSafeExecutor mainWorkerPool = new OrderedSafeExecutor(Runtime
-            .getRuntime().availableProcessors());
+    // used to call bookkeeper op in callback
+    final OrderedSafeExecutor callbackWorker;
+    final OrderedSafeExecutor mainWorkerPool;
 
     // Ledger manager responsible for how to store ledger meta data
     final LedgerManager ledgerManager;
@@ -140,6 +139,8 @@ public class BookKeeper {
                                                                 Executors.newCachedThreadPool());
         bookieWatcher = new BookieWatcher(this);
         bookieWatcher.readBookiesBlocking();
+        mainWorkerPool = new OrderedSafeExecutor(conf.getNumWorkerThreads());
+        callbackWorker = new OrderedSafeExecutor(conf.getNumWorkerThreads());
         bookieClient = new BookieClient(conf, channelFactory, mainWorkerPool);
         // initialize ledger meta manager
         ledgerManager = LedgerManagerFactory.newLedgerManager(conf, zk);
@@ -195,6 +196,8 @@ public class BookKeeper {
         this.channelFactory = channelFactory;
         bookieWatcher = new BookieWatcher(this);
         bookieWatcher.readBookiesBlocking();
+        mainWorkerPool = new OrderedSafeExecutor(conf.getNumWorkerThreads());
+        callbackWorker = new OrderedSafeExecutor(conf.getNumWorkerThreads());
         bookieClient = new BookieClient(conf, channelFactory, mainWorkerPool);
         // initialize ledger meta manager
         ledgerManager = LedgerManagerFactory.newLedgerManager(conf, zk);

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java?rev=1328452&r1=1328451&r2=1328452&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java Fri Apr 20 17:18:36 2012
@@ -40,6 +40,9 @@ public class ClientConfiguration extends
     protected final static String CLIENT_TCP_NODELAY = "clientTcpNoDelay";
     protected final static String READ_TIMEOUT = "readTimeout";
 
+    // Number Woker Threads
+    protected final static String NUM_WORKER_THREADS = "numWorkerThreads";
+
     /**
      * Construct a default client-side configuration
      */
@@ -235,4 +238,31 @@ public class ClientConfiguration extends
         setProperty(READ_TIMEOUT, Integer.toString(timeout));
         return this;
     }
+
+    /**
+     * Get the number of worker threads. This is the number of
+     * worker threads used by bookkeeper client to submit operations.
+     *
+     * @return the number of worker threads
+     */
+    public int getNumWorkerThreads() {
+        return getInt(NUM_WORKER_THREADS, Runtime.getRuntime().availableProcessors());
+    }
+
+    /**
+     * Set the number of worker threads.
+     *
+     * <p>
+     * NOTE: setting the number of worker threads after BookKeeper object is constructed
+     * will not take any effect on the number of threads in the pool.
+     * </p>
+     *
+     * @see #getNumWorkerThreads()
+     * @param numThreads number of worker threads used for bookkeeper
+     * @return client configuration
+     */
+    public ClientConfiguration setNumWorkerThreads(int numThreads) {
+        setProperty(NUM_WORKER_THREADS, numThreads);
+        return this;
+    }
 }

Added: zookeeper/bookkeeper/trunk/doc/bookieConfigParams.textile
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/doc/bookieConfigParams.textile?rev=1328452&view=auto
==============================================================================
--- zookeeper/bookkeeper/trunk/doc/bookieConfigParams.textile (added)
+++ zookeeper/bookkeeper/trunk/doc/bookieConfigParams.textile Fri Apr 20 17:18:36 2012
@@ -0,0 +1,46 @@
+Title:        Bookie Configuration Parameters
+Notice: Licensed under the Apache License, Version 2.0 (the "License");
+        you may not use this file except in compliance with the License. You may
+        obtain a copy of the License at "http://www.apache.org/licenses/LICENSE-2.0":http://www.apache.org/licenses/LICENSE-2.0.
+        .        
+        Unless required by applicable law or agreed to in writing,
+        software distributed under the License is distributed on an "AS IS"
+        BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+        implied. See the License for the specific language governing permissions
+        and limitations under the License.
+        .
+
+h1. Bookie Configuration Parameters
+
+This page contains detailed information about configuration parameters used for configuring a bookie server. There is an example in "bookkeeper-server/conf/bk_server.conf". 
+
+h3. General parameters
+
+| @zkServers@ | A list of one of more servers on which zookeeper is running. The server list can be comma separated values, e.g., zk1:2181,zk2:2181,zk3:2181 |
+| @zkTimeout@ | ZooKeeper client session timeout in milliseconds. Bookie server will exit if it received SESSION_EXPIRED because it was partitioned off from ZooKeeper for more than the session timeout JVM garbage collection, disk I/O will cause SESSION_EXPIRED. Increment this value could help avoiding this issue. The default value is 10,000. |
+| @bookiePort@        |Port that bookie server listens on. The default value is 3181.|
+| @journalDir@        | Directory Bookkeeper outputs its write ahead log, ideally in a dedicated device. The default value is "/tmp/bk-txn". |
+| @ledgerDirs@        | Directory Bookkeeper outputs ledger snapshots could define multiple directories to store snapshots, comma separated. For example: /tmp/bk1-data,/tmp/bk2-data. Ideally ledger dirs and journal dir are each in a differet device, which reduce the contention between random i/o and sequential write. It is possible to run with a single disk,  but performance will be significantly lower.|
+| @logSizeLimit@      | Maximum file size of entry logger, in bytes. A new entry log file will be created when the old one reaches the file size limitation. The default value is 2GB. |
+| @journalMaxSizeMB@  |  Maximum file size of journal file, in mega bytes. A new journal file will be created when the old one reaches the file size limitation. The default value is 2kB. |
+| @journalMaxBackups@ |  Max number of old journal file to keep. Keeping a number of old journal files might help data recovery in some special cases. The default value is 5. |
+| @gcWaitTime@        | Interval to trigger next garbage collection, in milliseconds. Since garbage collection is running in the background, running the garbage collector too frequently hurts performance. It is best to set its value high enough if there is sufficient disk capacity.|
+| @flushInterval@ | Interval to flush ledger index pages to disk, in milliseconds. Flushing index files will introduce random disk I/O. Consequently, it is important to have journal dir and ledger dirs each on different devices. However,  if it necessary to have journal dir and ledger dirs on the same device, one option is to increment the flush interval to get higher performance. Upon a failure, the bookie will take longer to recover. |
+| @bookieDeathWatchInterval@ | Interval to check whether a bookie is dead or not, in milliseconds. |
+
+h3. NIO server settings
+
+| @serverTcpNoDelay@ | This settings is used to enabled/disabled Nagle's algorithm, which is a means of improving the efficiency of TCP/IP networks by reducing the number of packets that need to be sent over the network. If you are sending many small messages, such that more than one can fit in a single IP packet, setting server.tcpnodelay to false to enable Nagle algorithm can provide better performance. Default value is true. |
+
+h3. Ledger cache settings
+
+| @openFileLimit@ | Maximum number of ledger index files that can be opened in a bookie. If the number of ledger index files reaches this limit, the bookie starts to flush some ledger indexes from memory to disk. If flushing happens too frequently, then performance is affected. You can tune this number to improve performance according. |
+| @pageSize@ | Size of an index page in ledger cache, in bytes. A larger index page can improve performance when writing page to disk, which is efficient when you have small number of ledgers and these ledgers have a similar number of entries. With a large number of ledgers and a few entries per ledger, a smaller index page would improves memory usage. |
+| @pageLimit@ | Maximum number of index pages to store in the ledger cache. If the number of index pages reaches this limit, bookie server starts to flush ledger indexes from memory to disk. Incrementing this value is an option when flushing becomes frequent. It is important to make sure, though, that pageLimit*pageSize is not more than JVM max memory limit; otherwise it will raise an OutOfMemoryException. In general, incrementing pageLimit, using smaller index page would gain better performance in the case of a large number of ledgers with few entries per ledger. If pageLimit is -1, a bookie uses 1/3 of the JVM memory to compute the maximum number of index pages. |
+
+h3. Ledger manager settings
+
+| @ledgerManagerType@ | What kind of ledger manager is used to manage how ledgers are stored, managed and garbage collected. See "BookKeeper Internals":./bookkeeperInternals.html for detailed info. Default is flat. |
+| @zkLedgersRootPath@ | Root zookeeper path to store ledger metadata. Default is /ledgers. |
+
+

Modified: zookeeper/bookkeeper/trunk/doc/bookkeeperConfig.textile
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/doc/bookkeeperConfig.textile?rev=1328452&r1=1328451&r2=1328452&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/doc/bookkeeperConfig.textile (original)
+++ zookeeper/bookkeeper/trunk/doc/bookkeeperConfig.textile Fri Apr 20 17:18:36 2012
@@ -41,7 +41,7 @@ The important parameters are:
 * @journalDir@, Path for Log Device (stores bookie write-ahead log); 
 * @ledgerDir@, Path for Ledger Device (stores ledger entries); 
 
-p. Ideally, @journalDir@ and @ledgerDir@ are each in a different device. See "BookKeeper Configuration Parameters":./bookkeeperConfigParams.html for a full list of configuration parameters.
+p. Ideally, @journalDir@ and @ledgerDir@ are each in a different device. See "Bookie Configuration Parameters":./bookieConfigParams.html for a full list of configuration parameters.
 
 h3. Upgrading
 

Modified: zookeeper/bookkeeper/trunk/doc/bookkeeperConfigParams.textile
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/doc/bookkeeperConfigParams.textile?rev=1328452&r1=1328451&r2=1328452&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/doc/bookkeeperConfigParams.textile (original)
+++ zookeeper/bookkeeper/trunk/doc/bookkeeperConfigParams.textile Fri Apr 20 17:18:36 2012
@@ -12,35 +12,28 @@ Notice: Licensed under the Apache Licens
 
 h1. BookKeeper Configuration Parameters
 
-This page contains detailed information about configuration parameters used for configuring a BookKeeper bookie. There is an example in "bookkeeper-server/conf/bk_server.conf". 
+This page contains detailed information about configuration parameters used for configuring a BookKeeper client.
 
 h3. General parameters
 
 | @zkServers@ | A list of one of more servers on which zookeeper is running. The server list can be comma separated values, e.g., zk1:2181,zk2:2181,zk3:2181 |
-| @zkTimeout@ | ZooKeeper client session timeout in milliseconds. Bookie server will exit if it received SESSION_EXPIRED because it was partitioned off from ZooKeeper for more than the session timeout JVM garbage collection, disk I/O will cause SESSION_EXPIRED. Increment this value could help avoiding this issue. The default value is 10,000. |
-| @bookiePort@        |Port that bookie server listens on. The default value is 3181.|
-| @journalDir@        | Directory Bookkeeper outputs its write ahead log, ideally in a dedicated device. The default value is "/tmp/bk-txn". |
-| @ledgerDirs@        | Directory Bookkeeper outputs ledger snapshots could define multiple directories to store snapshots, comma separated. For example: /tmp/bk1-data,/tmp/bk2-data. Ideally ledger dirs and journal dir are each in a differet device, which reduce the contention between random i/o and sequential write. It is possible to run with a single disk,  but performance will be significantly lower.|
-| @logSizeLimit@      | Maximum file size of entry logger, in bytes. A new entry log file will be created when the old one reaches the file size limitation. The default value is 2GB. |
-| @journalMaxSizeMB@  |  Maximum file size of journal file, in mega bytes. A new journal file will be created when the old one reaches the file size limitation. The default value is 2kB. |
-| @journalMaxBackups@ |  Max number of old journal file to keep. Keeping a number of old journal files might help data recovery in some special cases. The default value is 5. |
-| @gcWaitTime@        | Interval to trigger next garbage collection, in milliseconds. Since garbage collection is running in the background, running the garbage collector too frequently hurts performance. It is best to set its value high enough if there is sufficient disk capacity.|
-| @flushInterval@ | Interval to flush ledger index pages to disk, in milliseconds. Flushing index files will introduce random disk I/O. Consequently, it is important to have journal dir and ledger dirs each on different devices. However,  if it necessary to have journal dir and ledger dirs on the same device, one option is to increment the flush interval to get higher performance. Upon a failure, the bookie will take longer to recover. |
-| @bookieDeathWatchInterval@ | Interval to check whether a bookie is dead or not, in milliseconds. |
+| @zkTimeout@ | ZooKeeper client session timeout in milliseconds. The default value is 10,000. |
+| @throttle@ | A throttle value is used to prevent running out of memory when producing too many requests than the capability of bookie servers can handle. The default is 5,000. |
+| @readTimeout@ | This is the number of seconds bookkeeper client wait without hearing a response from a bookie before client consider it failed. The default is 5 seconds. |
+| @numWorkerThreads@ | This is the number of worker threads used by bookkeeper client to submit operations. The default value is the number of available processors. |
 
 h3. NIO server settings
 
-| @serverTcpNoDelay@ | This settings is used to enabled/disabled Nagle's algorithm, which is a means of improving the efficiency of TCP/IP networks by reducing the number of packets that need to be sent over the network. If you are sending many small messages, such that more than one can fit in a single IP packet, setting server.tcpnodelay to false to enable Nagle algorithm can provide better performance. Default value is true. |
-
-h3. Ledger cache settings
-
-| @openFileLimit@ | Maximum number of ledger index files that can be opened in a bookie. If the number of ledger index files reaches this limit, the bookie starts to flush some ledger indexes from memory to disk. If flushing happens too frequently, then performance is affected. You can tune this number to improve performance according. |
-| @pageSize@ | Size of an index page in ledger cache, in bytes. A larger index page can improve performance when writing page to disk, which is efficient when you have small number of ledgers and these ledgers have a similar number of entries. With a large number of ledgers and a few entries per ledger, a smaller index page would improves memory usage. |
-| @pageLimit@ | Maximum number of index pages to store in the ledger cache. If the number of index pages reaches this limit, bookie server starts to flush ledger indexes from memory to disk. Incrementing this value is an option when flushing becomes frequent. It is important to make sure, though, that pageLimit*pageSize is not more than JVM max memory limit; otherwise it will raise an OutOfMemoryException. In general, incrementing pageLimit, using smaller index page would gain better performance in the case of a large number of ledgers with few entries per ledger. If pageLimit is -1, a bookie uses 1/3 of the JVM memory to compute the maximum number of index pages. |
+| @clientTcpNoDelay@ | This settings is used to enabled/disabled Nagle's algorithm, which is a means of improving the efficiency of TCP/IP networks by reducing the number of packets that need to be sent over the network. If you are sending many small messages, such that more than one can fit in a single IP packet, setting server.tcpnodelay to false to enable Nagle algorithm can provide better performance. Default value is true. |
 
 h3. Ledger manager settings
 
-| @ledgerManagerType@ | What kind of ledger manager is used to manage how ledgers are stored, managed and garbage collected. See "BookKeeper Internals":./bookkeeperInternals.html for detailed info. Default is flat. |
+| @ledgerManagerType@ | This parameter determines the type of ledger manager used to manage how ledgers are stored, manipulated, and garbage collected. See "BookKeeper Internals":./bookkeeperInternals.html for detailed info. Default value is flat. |
 | @zkLedgersRootPath@ | Root zookeeper path to store ledger metadata. Default is /ledgers. |
 
+h3. Bookie recovery settings
+
+Currently bookie recovery tool needs a digest type and passwd to open ledgers to do recovery. Currently, bookkeeper assumes that all ledgers were created with the same DigestType and Password. In the future, it needs to know for each ledger, what was the DigestType and Password used to create it before opening it.
 
+| @digestType@ | Digest type used to open ledgers from bookkie recovery tool. |
+| @passwd@ | Password used to open ledgers from bookie recovery tool. |

Modified: zookeeper/bookkeeper/trunk/doc/index.textile
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/doc/index.textile?rev=1328452&r1=1328451&r2=1328452&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/doc/index.textile (original)
+++ zookeeper/bookkeeper/trunk/doc/index.textile Fri Apr 20 17:18:36 2012
@@ -22,7 +22,8 @@ h1. Apache BookKeeper documentation
 * "Getting started":./bookkeeperStarted.html
 * "Programmer's Guide":./bookkeeperProgrammer.html
 * "Admin Guide":./bookkeeperConfig.html
-* "Bookie Server Configuration Parameters":./bookkeeperConfigParams.html
+* "Bookie Server Configuration Parameters":./bookieConfigParams.html
+* "BookKeeper Configuration Parameters":./bookkeeperConfigParams.html
 * "BookKeeper Internals":./bookkeeperInternals.html
 * "Bookie Recovery":./bookieRecovery.html
 * "Using BookKeeper stream library":./bookkeeperStream.html