Skip to content

Commit 544f4b5

Browse files
committed
BOOKKEEPER-122: Review BookKeeper server documentation (fpj & ivank)
git-svn-id: https://svn.apache.org/repos/asf/zookeeper/bookkeeper/trunk@1208123 13f79535-47bb-0310-9956-ffa450edef68
1 parent e3b52e8 commit 544f4b5

File tree

12 files changed

+71
-121
lines changed

12 files changed

+71
-121
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ BUGFIXES:
1515
BOOKKEEPER-127: Make poms use official zookeeper 3.4.0 (ivank)
1616

1717
BOOKKEEPER-120: Review BookKeeper client documentation (ivank)
18+
19+
BOOKKEEPER-122: Review BookKeeper server documentation (fpj & ivank)
1820

1921
bookkeeper-server/
2022

bookkeeper-server/conf/bk_server.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ledgerDirectories=/tmp/bk-data
4040

4141
# Ledger Manager Class
4242
# What kind of ledger manager is used to manage how ledgers are stored, managed
43-
# and garbage collected. Try to read 'BookKeeper Overview' for detail info.
43+
# and garbage collected. Try to read 'BookKeeper Internals' for detail info.
4444
# ledgerManagerType=flat
4545

4646
# Root zookeeper path to store ledger metadata

bookkeeper-server/src/main/java/org/apache/bookkeeper/client/AsyncCallback.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public interface AddCallback {
2626
*
2727
* @param rc
2828
* return code
29-
* @param ledgerId
30-
* ledger identifier
29+
* @param lh
30+
* ledger handle
3131
* @param entryId
3232
* entry identifier
3333
* @param ctx
@@ -42,8 +42,8 @@ public interface CloseCallback {
4242
*
4343
* @param rc
4444
* return code
45-
* @param ledgerId
46-
* ledger identifier
45+
* @param lh
46+
* ledger handle
4747
* @param ctx
4848
* control object
4949
*/
@@ -87,8 +87,8 @@ public interface ReadCallback {
8787
*
8888
* @param rc
8989
* return code
90-
* @param ledgerId
91-
* ledger identifier
90+
* @param lh
91+
* ledger handle
9292
* @param seq
9393
* sequence of entries
9494
* @param ctx

bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public void asyncCreateLedger(int ensSize, int qSize, DigestType digestType,
251251
* digest type, either MAC or CRC32
252252
* @param passwd
253253
* password
254-
* @return
254+
* @return a handle to the newly created ledger
255255
* @throws InterruptedException
256256
* @throws BKException
257257
*/
@@ -262,13 +262,14 @@ public LedgerHandle createLedger(DigestType digestType, byte passwd[])
262262

263263
/**
264264
* Synchronous call to create ledger. Parameters match those of
265-
* {@link #asyncCreateLedger(int, int, DigestType, byte[], CreateCallback, Object)}
265+
* {@link #asyncCreateLedger(int, int, DigestType, byte[],
266+
* AsyncCallback.CreateCallback, Object)}
266267
*
267268
* @param ensSize
268269
* @param qSize
269270
* @param digestType
270271
* @param passwd
271-
* @return
272+
* @return a handle to the newly created ledger
272273
* @throws InterruptedException
273274
* @throws BKException
274275
*/
@@ -369,7 +370,7 @@ public void asyncOpenLedgerNoRecovery(long lId, DigestType digestType, byte pass
369370
* digest type, either MAC or CRC32
370371
* @param passwd
371372
* password
372-
* @return
373+
* @return a handle to the open ledger
373374
* @throws InterruptedException
374375
* @throws BKException
375376
*/
@@ -404,7 +405,7 @@ public LedgerHandle openLedger(long lId, DigestType digestType, byte passwd[])
404405
* digest type, either MAC or CRC32
405406
* @param passwd
406407
* password
407-
* @return
408+
* @return a handle to the open ledger
408409
* @throws InterruptedException
409410
* @throws BKException
410411
*/
@@ -447,7 +448,7 @@ public void asyncDeleteLedger(long lId, DeleteCallback cb, Object ctx) {
447448

448449
/**
449450
* Synchronous call to delete a ledger. Parameters match those of
450-
* {@link #asyncDeleteLedger(long, DeleteCallback, Object)}
451+
* {@link #asyncDeleteLedger(long, AsyncCallback.DeleteCallback, Object)}
451452
*
452453
* @param lId
453454
* ledgerId

bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public class LedgerHandle {
100100
/**
101101
* Get the id of the current ledger
102102
*
103-
* @return
103+
* @return the id of the ledger
104104
*/
105105
public long getId() {
106106
return ledgerId;
@@ -109,7 +109,7 @@ public long getId() {
109109
/**
110110
* Get the last confirmed entry id on this ledger
111111
*
112-
* @return
112+
* @return the last confirmed entry id
113113
*/
114114
public long getLastAddConfirmed() {
115115
return lastAddConfirmed;
@@ -119,7 +119,7 @@ public long getLastAddConfirmed() {
119119
* Get the entry id of the last entry that has been enqueued for addition (but
120120
* may not have possibly been persited to the ledger)
121121
*
122-
* @return
122+
* @return the id of the last entry pushed
123123
*/
124124
public long getLastAddPushed() {
125125
return lastAddPushed;
@@ -175,7 +175,7 @@ long addToLength(long delta) {
175175
/**
176176
* Returns the length of the ledger in bytes.
177177
*
178-
* @return
178+
* @return the length of the ledger in bytes
179179
*/
180180
public long getLength() {
181181
return this.length;

bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,9 @@ long getNextEnsembleChange(long entryId) {
133133
}
134134

135135
/**
136-
* Generates a byte array based on a LedgerConfig object received.
136+
* Generates a byte array of this object
137137
*
138-
* @param config
139-
* LedgerConfig object
140-
* @return byte[]
138+
* @return the metadata serialized into a byte array
141139
*/
142140
public byte[] serialize() {
143141
StringBuilder s = new StringBuilder();

doc/bookkeeperConfig.textile

Lines changed: 21 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -16,102 +16,42 @@ h1. Abstract
1616

1717
This document contains information about deploying, administering and mantaining BookKeeper. It also discusses best practices and common problems.
1818

19-
As BookKeeper is still a prototype, this article is likely to change significantly over time.
19+
h1. Running a BookKeeper instance
2020

21-
h1. System requirements
21+
h2. System requirements
2222

23-
p. A typical BookKeeper installation comprises a set of bookies and a set of ZooKeeper replicas. The exact number of bookies depends on the quorum mode, desired throughput, and number of clients using this installation simultaneously. The minimum number of bookies is three for self-verifying (stores a message authentication code along with each entry) and four for generic (does not store a message authentication codewith each entry), and there is no upper limit on the number of bookies. Increasing the number of bookies, in fact, enables higher throughput.
23+
p. A typical BookKeeper installation comprises a set of bookies and a set of ZooKeeper replicas. The exact number of bookies depends on the quorum mode, desired throughput, and number of clients using this installation simultaneously. The minimum number of bookies is three for self-verifying (stores a message authentication code along with each entry) and four for generic (does not store a message authentication code with each entry), and there is no upper limit on the number of bookies. Increasing the number of bookies will, in fact, enable higher throughput.
2424

25-
p. For performance, we require each server to have at least two disks. It is possible to run a bookie with a single disk, but performance will be significantly lower in this case. Of course, it works with one disk, but performance is significantly lower.
25+
p. For performance, we require each server to have at least two disks. It is possible to run a bookie with a single disk, but performance will be significantly lower in this case.
2626

27-
p. For ZooKeeper, there is no constraint with respect to the number of replicas. Having a single machine running ZooKeeper in standalone mode is sufficient for BookKeeper. For resilience purposes, it might be a good idea to run ZooKeeper in quorum mode with multiple servers. Please refer to the ZooKeeper documentation for detail on how to configure ZooKeeper with multiple replicas
27+
p. For ZooKeeper, there is no constraint with respect to the number of replicas. Having a single machine running ZooKeeper in standalone mode is sufficient for BookKeeper. For resilience purposes, it might be a good idea to run ZooKeeper in quorum mode with multiple servers. Please refer to the ZooKeeper documentation for detail on how to configure ZooKeeper with multiple replicas.
2828

29-
h1. Running bookies
29+
h2. Running bookies
3030

3131
p. To run a bookie, we execute the following command:
3232

33-
@ bookkeeper-server/bin/bookkeeper bookie
33+
@bookkeeper-server/bin/bookkeeper bookie@
3434

35-
p. The configuration parameters, which can be set in bookkeeper-server/conf/bkenv.sh
35+
p. The configuration parameters can be set in bookkeeper-server/conf/bk_server.conf.
3636

37-
* BOOKIE_PORT: Port number that the bookie listens on;
38-
* BOOKIE_ZOOKEEPER: Comma separated list of ZooKeeper servers with a hostname:port format;
39-
* BOOKIE_TXN_LOGDIR: Path for Log Device (stores bookie write-ahead log);
40-
* BOOKIE_DATA_DIR: Path for Ledger Device (stores ledger entries);
37+
The important parameters are:
38+
* @bookiePort@, Port number that the bookie listens on;
39+
* @zkServers@, Comma separated list of ZooKeeper servers with a hostname:port format;
40+
* @journalDir@, Path for Log Device (stores bookie write-ahead log);
41+
* @ledgerDir@, Path for Ledger Device (stores ledger entries);
4142

42-
p. Ideally, @/path_to_log_device/@ and @/path_to_ledger_device/@ are each in a different device.
43+
p. Ideally, @journalDir@ and @ledgerDir@ are each in a different device. See "BookKeeper Configuration Parameters":./bookkeeperConfigParams.html for a full list of configuration parameters.
4344

44-
h1. Bookie Configuration
4545

46-
p. Bookie server stores its data in multiple ledger directories and its journal files in a journal directory. Ideally, storing journal files in a separate directory than data files would increase throughput and decrease latency.
46+
h3. Logging
4747

48-
h2. Journal Configuration
48+
BookKeeper uses "slf4j":http://www.slf4j.org for logging, with the log4j bindings enabled by default. To enable logging from a bookie, create a log4j.properties file and point the environment variable BOOKIE_LOG_CONF to the configuration file. The path to the log4j.properties file must be absolute.
4949

50-
p. Journal directory has one kind of files in it:
50+
@export BOOKIE_LOG_CONF=/tmp/log4j.properties@
51+
@bookkeeper-server/bin/bookkeeper bookie@
5152

52-
* {timestamp}.txn - holds transactions executed in the bookie server.
53+
h2. Setting up a test ensemble
5354

54-
p. Before persisting ledger index and data to disk, a bookie ensures that the transaction that represents the update is written to a journal in non-volatile storage. A new journal file is created using current timestamp when a bookie starts or an old journal file reaches its maximum size.
55+
Sometimes it is useful to run a ensemble of bookies on your local machine for testing. We provide a utility for doing this. It will set up N bookies, and a zookeeper instance locally. The data on these bookies and of the zookeeper instance are not persisted over restarts, so obviously this should never be used in a production environment. To run a test ensemble of 10 bookies, do the following.
5556

56-
p. A bookie supports journal rolling to remove old journal files. In order to remove old journal files safely, bookie server records LastLogMark in Ledger Device, which indicates all updates (including index and data) before LastLogMark has been persisted to the Ledger Device.
57-
58-
p. LastLogMark contains two parts:
59-
60-
* LastLogId - indicates which journal file the transaction persisted.
61-
* LastLogPos - indicates the position the transaction persisted in LastLogId journal file.
62-
63-
p. You may use following settings to further fine tune the behavior of your Bookie servers. Currently these configuration settings are set using Java system properties.
64-
65-
* journalMaxSizeMB
66-
** journal file size limitation. when a journal reaches this limitation, it will be closed and new journal file be created.
67-
68-
* journalMaxBackups
69-
** how many old journal files whose id is less than LastLogMark 's journal id.
70-
71-
bq. NOTE: keeping number of old journal files would be useful for manually recovery in special case.
72-
73-
h1. ZooKeeper Metadata
74-
75-
p. For BookKeeper, we require a ZooKeeper installation to store metadata, and to pass the list of ZooKeeper servers as parameter to the constructor of the BookKeeper class ( @org.apache.bookkeeper.client,BookKeeper@ ). To setup ZooKeeper, please check the "ZooKeeper documentation":index.html.
76-
77-
p. BookKeeper provides two mechnaisms to organize its metadata in ZooKeeper.
78-
79-
* FlatLedgerManager : All ledger metadata are placed as children in a single zookeeper path.
80-
* HierarchicalLedgerManager : All ledger metadata are partitioned into 2-level znodes.
81-
82-
h2. Flat Ledger Manager
83-
84-
p. All ledgers' metadata are put in a single zookeeper path, created using zookeeper sequential node, which can ensure uniqueness of ledger id. Each ledger node is prefixed with 'L'.
85-
86-
p. Bookie server manages its owned active ledgers in a hash map. So it is easy for bookie server to find what ledgers are deleted from zookeeper and garbage collect them. And its garbage collection flow is described as below:
87-
88-
* Fetch all existing ledgers from zookeeper (*zkActiveLedgers*).
89-
* Fetch all ledgers currently active within the Bookie (*bkActiveLedgers*).
90-
* Loop over *bkActiveLedgers* to find those ledgers which do not exist in *zkActiveLedgers* and garbage collect them.
91-
92-
h2. Hierarchical Ledger Manager
93-
94-
p. Hierarchical Ledger Manager first obtains a global unique id from ZooKeeper using a EPHEMERAL_SEQUENTIAL znode.
95-
96-
p. Since ZooKeeper sequential counter has a format of %10d -- that is 10 digits with 0 (zero) padding, i.e. "<path>0000000001", HierarchicalLedgerManager splits the generated id into 3 parts :
97-
98-
@ {level1 (2 digits)}{level2 (4 digits)}{level3 (4 digits)}
99-
100-
p. These 3 parts are used to form the actual ledger node path used to store ledger metadata:
101-
102-
@ {ledgers_root_path}/{level1}/{level2}/L{level3}
103-
104-
p. E.g. Ledger 0000000001 is split into 3 parts 00, 0000, 00001, which is stored in znode /{ledgers_root_path}/00/0000/L0001. So each znode could have at most 10000 ledgers, which avoids the problem of the child list being larger than the maximum ZooKeeper packet size.
105-
106-
p. Bookie server manages its active ledgers in a sorted map, which simplifies access to active ledgers in a particular (level1, level2) partition.
107-
108-
p. Garbage collection in bookie server is processed node by node as follows:
109-
110-
* Fetching all level1 nodes, by calling zk#getChildren(ledgerRootPath).
111-
** For each level1 nodes, fetching their level2 nodes :
112-
** For each partition (level1, level2) :
113-
*** Fetch all existed ledgers from zookeeper belonging to partition (level1, level2) (*zkActiveLedgers*).
114-
*** Fetch all ledgers currently active in the bookie which belong to partition (level1, level2) (*bkActiveLedgers*).
115-
*** Loop over *bkActiveLedgers* to find those ledgers which do not exist in *zkActiveLedgers*, and garbage collect them.
116-
117-
bq. NOTE: Hierarchical Ledger Manager is more suitable to manage large number of ledgers existed in BookKeeper.
57+
@bookkeeper-server/bin/bookkeeper localbookie 10@

0 commit comments

Comments
 (0)