Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve] Support specifying multiple journalDirs for the bookie server start cmd options #4181

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public class Main {
BK_OPTS.addOption("m", "zkledgerpath", true, "Zookeeper ledgers root path");
BK_OPTS.addOption("p", "bookieport", true, "bookie port exported");
BK_OPTS.addOption("hp", "httpport", true, "bookie http port exported");
BK_OPTS.addOption("j", "journal", true, "bookie journal directory");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a broken change? What happens if people still use BK_journalDirectory instead of BK_journalDirectories after upgrading?

We can retain the original parameters to ensure compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't break compatibility

Option journalDirs = new Option ("j", "journaldirs", true, "bookie journal directories");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eolivelli I didn't break the compatibility

journalDirs.setArgs(10);
BK_OPTS.addOption(journalDirs);
Option indexDirs = new Option ("i", "indexdirs", true, "bookie index directories");
indexDirs.setArgs(10);
BK_OPTS.addOption(indexDirs);
Expand All @@ -81,8 +83,10 @@ private static void printUsage() {
+ "The settings in configuration file will be overwrite by provided arguments.\n"
+ "Options including:\n";
String footer = "Here is an example:\n"
+ "\tBookieServer -c bookie.conf -z localhost:2181 -m /bookkeeper/ledgers "
+ "-p 3181 -j /mnt/journal -i \"/mnt/index1 /mnt/index2\""
+ "\tBookieServer -c bookie.conf -z localhost:2181 -m /bookkeeper/ledgers"
+ " -p 3181"
+ " -j \"/mnt/journal1 /mnt/journal2\""
+ " -i \"/mnt/index1 /mnt/index2\""
+ " -l \"/mnt/ledger1 /mnt/ledger2 /mnt/ledger3\"\n";
hf.printHelp("BookieServer [options]\n", header, BK_OPTS, footer, true);
}
Expand Down Expand Up @@ -165,9 +169,12 @@ private static ServerConfiguration parseArgs(String[] args)
}

if (cmdLine.hasOption('j')) {
String sJournalDir = cmdLine.getOptionValue('j');
log.info("Get cmdline journal dir: {}", sJournalDir);
conf.setJournalDirName(sJournalDir);
String[] sJournalDirs = cmdLine.getOptionValues('j');
log.info("Get cmdline journal dirs: ");
for (String journal : sJournalDirs) {
log.info("journalDir : {}", journal);
}
conf.setJournalDirsName(sJournalDirs);
}

if (cmdLine.hasOption('i')) {
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/gke/bookkeeper.statefulset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ metadata:
data:
BK_BOOKIE_EXTRA_OPTS: "\"-Xms1g -Xmx1g -XX:MaxDirectMemorySize=1g -XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+DoEscapeAnalysis -XX:ParallelGCThreads=32 -XX:ConcGCThreads=32 -XX:G1NewSizePercent=50 -XX:+DisableExplicitGC -XX:-ResizePLAB\""
BK_bookiePort: "3181"
BK_journalDirectory: "/bookkeeper/data/journal"
BK_journalDirectories: "/bookkeeper/data/journal"
BK_ledgerDirectories: "/bookkeeper/data/ledgers"
BK_indexDirectories: "/bookkeeper/data/ledgers"
BK_zkServers: zookeeper
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/gke/bookkeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ metadata:
data:
BK_BOOKIE_EXTRA_OPTS: "\"-Xms1g -Xmx1g -XX:MaxDirectMemorySize=1g -XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+DoEscapeAnalysis -XX:ParallelGCThreads=32 -XX:ConcGCThreads=32 -XX:G1NewSizePercent=50 -XX:+DisableExplicitGC -XX:-ResizePLAB\""
BK_bookiePort: "3181"
BK_journalDirectory: "/bookkeeper/data/journal"
BK_journalDirectories: "/bookkeeper/data/journal"
BK_ledgerDirectories: "/bookkeeper/data/ledgers"
BK_indexDirectories: "/bookkeeper/data/ledgers"
BK_zkServers: zookeeper
Expand Down
2 changes: 1 addition & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Default value is empty - " ". so ledgers dir in zookeeper will be at "/ledgers"
#### `BK_DATA_DIR`
This variable allows you to specify where to store data in docker instance.

This could be override by env vars "BK_journalDirectory", "BK_ledgerDirectories", "BK_indexDirectories" and also `journalDirectory`, `ledgerDirectories`, `indexDirectories` in [bk_server.conf](https://github.com/apache/bookkeeper/blob/master/bookkeeper-server/conf/bk_server.conf).
This could be override by env vars "BK_journalDirectories", "BK_ledgerDirectories", "BK_indexDirectories" and also `journalDirectories`, `ledgerDirectories`, `indexDirectories` in [bk_server.conf](https://github.com/apache/bookkeeper/blob/master/conf/bk_server.conf).

Default value is "/data/bookkeeper", which contains volumes `/data/bookkeeper/journal`, `/data/bookkeeper/ledgers` and `/data/bookkeeper/index` to hold Bookkeeper data in docker.

Expand Down
10 changes: 5 additions & 5 deletions docker/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export BK_metadataServiceUri=${BK_metadataServiceUri:-"zk://${BK_zkServers}${BK_
export BK_bookiePort=${BK_bookiePort:-${PORT0}}
export BK_httpServerEnabled=${BK_httpServerEnabled:-"true"}
export BK_httpServerPort=${BK_httpServerPort:-${BOOKIE_HTTP_PORT}}
export BK_journalDirectory=${BK_journalDirectory:-${BK_DATA_DIR}/journal}
export BK_journalDirectories=${BK_journalDirectories:-${BK_journalDirectory:-${BK_DATA_DIR}/journal}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export BK_ledgerDirectories=${BK_ledgerDirectories:-${BK_DATA_DIR}/ledgers}
export BK_indexDirectories=${BK_indexDirectories:-${BK_ledgerDirectories}}
# dlog
Expand All @@ -55,7 +55,7 @@ echo ""
echo " [bookie]"
echo " BK_bookiePort bookie service port is $BK_bookiePort"
echo " BK_DATA_DIR is $BK_DATA_DIR"
echo " BK_journalDirectory is ${BK_journalDirectory}"
echo " BK_journalDirectories is ${BK_journalDirectories}"
echo " BK_ledgerDirectories are ${BK_ledgerDirectories}"
echo " BK_indexDirectories are ${BK_indexDirectories}"
echo ""
Expand All @@ -77,15 +77,15 @@ export BOOKIE_CONF=${BK_HOME}/conf/bk_server.conf
export SERVICE_PORT=${PORT0}

function create_bookie_dirs() {
mkdir -p "${BK_journalDirectory}" "${BK_ledgerDirectories}" "${BK_indexDirectories}"
mkdir -p "${BK_journalDirectories}" "${BK_ledgerDirectories}" "${BK_indexDirectories}"
echo "Created bookie dirs : "
echo " journal = ${BK_journalDirectory}"
echo " journal = ${BK_journalDirectories}"
echo " ledger = ${BK_ledgerDirectories}"
echo " index = ${BK_indexDirectories}"
# -------------- #
# Allow the container to be started with `--user`
if [ "$(id -u)" = '0' ]; then
chown -R "${BK_USER}:${BK_USER}" "${BK_journalDirectory}" "${BK_ledgerDirectories}" "${BK_indexDirectories}"
chown -R "${BK_USER}:${BK_USER}" "${BK_journalDirectories}" "${BK_ledgerDirectories}" "${BK_indexDirectories}"
fi
# -------------- #
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

mkdir -p $BK_JOURNALDIR $BK_LEDGERDIR

sed -i "s|journalDirectory=.*|journalDirectory=$BK_JOURNALDIR|" /opt/bookkeeper/*/conf/bk_server.conf
sed -i "s|journalDirectories=.*|journalDirectories=$BK_JOURNALDIR|" /opt/bookkeeper/*/conf/bk_server.conf
sed -i "s|ledgerDirectories=.*|ledgerDirectories=$BK_LEDGERDIR|" /opt/bookkeeper/*/conf/bk_server.conf
sed -i "s|zkServers=.*|zkServers=$BK_ZKCONNECTSTRING|" /opt/bookkeeper/*/conf/bk_server.conf

Expand Down