You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2020/01/22 10:23:07 UTC

[bookkeeper] branch master updated: bin/bookkeeper shell supports the -conf

This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 163db44  bin/bookkeeper shell supports the -conf
163db44 is described below

commit 163db4496d50cae198b80c9d88c14579f6d2e9f3
Author: Dapeng <su...@cmss.chinamobile.com>
AuthorDate: Wed Jan 22 18:22:56 2020 +0800

    bin/bookkeeper shell supports the -conf
    
    ### Motivation
    `bin/bookkeeper shell ` support `-conf configuration`, but it doesn't work. bk_server.conf is loaded by default, even if the configuration is specified
    ![image](https://user-images.githubusercontent.com/42792537/70309755-2a534180-1849-11ea-96b0-bd5b07a6b717.png)
    Modify `bin/bookkeeper` to specify the configuration file as an absolute path
    
    
    
    Reviewers: Enrico Olivelli <eo...@gmail.com>, Sijie Guo <None>
    
    This closes #2211 from SunDapeng1/branch-2211
---
 bin/bookkeeper | 40 +++++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/bin/bookkeeper b/bin/bookkeeper
index ddaae22..4b55d1e 100755
--- a/bin/bookkeeper
+++ b/bin/bookkeeper
@@ -108,16 +108,30 @@ shift
 LOCALBOOKIES_CONFIG_DIR="${LOCALBOOKIES_CONFIG_DIR:-/tmp/localbookies-config}"
 if [ ${COMMAND} == "shell" ]; then
   DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j.shell.properties
-  if [[ $1 == "-localbookie"  ]]; then
-    if [[ $2 == *:* ]];
-    then
-      BOOKIE_CONF=${LOCALBOOKIES_CONFIG_DIR}/$2.conf
-      shift 2
-    else
-      BOOKIE_CONF=${LOCALBOOKIES_CONFIG_DIR}/baseconf.conf
-      shift
-    fi
-  fi
+  LOCALBOOKIE=0
+   while [ $# -gt 0 ]
+    do
+       opt="$1"
+       case $opt in
+         (-conf)
+            BOOKIE_CONF="$2"
+            shift 2
+         ;;
+         (-localbookie)
+            LOCALBOOKIE=1
+            if [[ $2 == *:* ]];
+            then
+               LOCALBOOKIE_CONF=${LOCALBOOKIES_CONFIG_DIR}/$2.conf
+               shift 2
+            else
+               LOCALBOOKIE_CONF=${LOCALBOOKIES_CONFIG_DIR}/baseconf.conf
+               shift
+            fi
+         ;;
+         (*)
+         ;;
+       esac
+    done
 fi
 
 if [ -z "$BOOKIE_ZK_CONF" ]; then
@@ -172,7 +186,11 @@ elif [ $COMMAND == "zookeeper" ]; then
     exec $JAVA $OPTS -Dbookkeeper.log.file=$BOOKIE_LOG_FILE org.apache.zookeeper.server.quorum.QuorumPeerMain $BOOKIE_ZK_CONF $@
 elif [ ${COMMAND} == "shell" ]; then
   ENTRY_FORMATTER_ARG="-DentryFormatterClass=${ENTRY_FORMATTER_CLASS:-org.apache.bookkeeper.util.StringEntryFormatter}"
-  exec ${JAVA} ${OPTS} ${ENTRY_FORMATTER_ARG} org.apache.bookkeeper.bookie.BookieShell -conf ${BOOKIE_CONF} $@
+  if [ ${LOCALBOOKIE} == 1 ]; then
+             exec ${JAVA} ${OPTS} ${ENTRY_FORMATTER_ARG} org.apache.bookkeeper.bookie.BookieShell -conf ${LOCALBOOKIE_CONF} $@
+     else
+             exec ${JAVA} ${OPTS} ${ENTRY_FORMATTER_ARG} org.apache.bookkeeper.bookie.BookieShell -conf ${BOOKIE_CONF} $@
+     fi
 elif [ ${COMMAND} == "help" ]; then
   bookkeeper_help;
 else