This is an automated email from the ASF dual-hosted git repository.
ivank 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 2a5e37c [SCRIPTS] improve bookkeeper script to better handle
standalone command
2a5e37c is described below
commit 2a5e37c186387998aa0d7cf36766777d7e194151
Author: Sijie Guo <[email protected]>
AuthorDate: Thu Nov 22 16:03:15 2018 -0800
[SCRIPTS] improve bookkeeper script to better handle standalone command
Descriptions of the changes in this PR:
*Motivation*
`bin/bookkeeper standalone` is broken when a release package is built
without including `stream` profile.
*Changes*
`standalone` is a service component including everything. so fail the
command if it can't locate corresponding components.
Related Issues: #1822
Reviewers: Ivan Kelly <[email protected]>, Enrico Olivelli
<[email protected]>
This closes #1823 from sijie/refactor_bookkeeper_scripts
---
bin/bookkeeper | 34 ++++++++++++++---------
bin/common.sh | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 104 insertions(+), 16 deletions(-)
diff --git a/bin/bookkeeper b/bin/bookkeeper
index 70b6ccd..ddaae22 100755
--- a/bin/bookkeeper
+++ b/bin/bookkeeper
@@ -35,21 +35,17 @@ else
BOOKIE_CONF_TO_CHECK=${BOOKIE_CONF}
fi
-# check the configuration to see if table service is enabled or not.
-if [ -z "${ENABLE_TABLE_SERVICE}" ]; then
- # mask exit code if the configuration file doesn't contain
`StreamStorageLifecycleComponent`
- TABLE_SERVICE_SETTING=$(grep StreamStorageLifecycleComponent
${BOOKIE_CONF_TO_CHECK} | cat)
- if [[ "${TABLE_SERVICE_SETTING}" =~ ^extraServerComponents.* ]]; then
- ENABLE_TABLE_SERVICE="true"
- fi
-fi
+FIND_TABLE_SERVICE_RESULT=$(find_table_service ${BOOKIE_CONF_TO_CHECK} $1)
-if [ \( "x$1" == "xstandalone" \) -o \( "x${ENABLE_TABLE_SERVICE}" == "xtrue"
\) ]; then
+if [ "x${FIND_TABLE_SERVICE_RESULT}" == "xtrue" ]; then
BOOKIE_MODULE_PATH=stream/server
- BOOKIE_MODULE_NAME="(org.apache.bookkeeper-)?stream-storage-server"
-else
+ BOOKIE_MODULE_NAME=${TABLE_SERVICE_MODULE_NAME}
+elif [ "x${FIND_TABLE_SERVICE_RESULT}" == "xfalse" ]; then
BOOKIE_MODULE_PATH=bookkeeper-server
- BOOKIE_MODULE_NAME="(org.apache.bookkeeper-)?bookkeeper-server"
+ BOOKIE_MODULE_NAME=${BOOKIE_SERVER_MODULE_NAME}
+else
+ echo ${FIND_TABLE_SERVICE_RESULT}
+ exit 1
fi
# find the module jar
@@ -62,13 +58,25 @@ bookkeeper_help() {
cat <<EOF
Usage: bookkeeper <command>
where command is one of:
+
+[service commands]
+
bookie Run a bookie server
autorecovery Run AutoRecovery service daemon
+ zookeeper Run zookeeper server
+
+[development commands]
+
localbookie <n> Run a test ensemble of <n> bookies locally
standalone Run a standalone cluster (with all service components)
locally
+
+[tooling commands]
+
upgrade Upgrade bookie filesystem
shell Run shell for admin commands
- zookeeper Run zookeeper server
+
+[other commands]
+
help This help message
or command is the full name of a class with a defined main() method.
diff --git a/bin/common.sh b/bin/common.sh
index 73de28f..f92c0b9 100755
--- a/bin/common.sh
+++ b/bin/common.sh
@@ -114,6 +114,20 @@ CLI_MEM_OPTS=${CLI_MEM_OPTS:-"-Xms${CLI_MIN_HEAP_MEMORY}
-Xmx${CLI_MAX_HEAP_MEMO
CLI_GC_OPTS=${CLI_GC_OPTS:-"${DEFAULT_CLI_GC_OPTS}"}
CLI_GC_LOGGING_OPTS=${CLI_GC_LOGGING_OPTS:-"${DEFAULT_CLI_GC_LOGGING_OPTS}"}
+# module names
+BOOKIE_SERVER_MODULE_NAME="(org.apache.bookkeeper-)?bookkeeper-server"
+TABLE_SERVICE_MODULE_NAME="(org.apache.bookkeeper-)?stream-storage-server"
+
+is_released_binary() {
+ if [ -d ${BK_HOME}/lib ]; then
+ echo "true"
+ return
+ else
+ echo "false"
+ return
+ fi
+}
+
find_module_jar_at() {
DIR=$1
MODULE=$2
@@ -129,6 +143,21 @@ find_module_jar_at() {
fi
}
+find_module_release_jar() {
+ MODULE_NAME=$1
+ RELEASE_JAR=$(find_module_jar_at ${BK_HOME} ${MODULE_NAME})
+ if [ -n "${RELEASE_JAR}" ]; then
+ MODULE_JAR=${RELEASE_JAR}
+ else
+ RELEASE_JAR=$(find_module_jar_at ${BK_HOME}/lib ${MODULE_NAME})
+ if [ -n "${RELEASE_JAR}" ]; then
+ MODULE_JAR=${RELEASE_JAR}
+ fi
+ fi
+ echo ${RELEASE_JAR}
+ return
+}
+
find_module_jar() {
MODULE_PATH=$1
MODULE_NAME=$2
@@ -146,10 +175,13 @@ find_module_jar() {
BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/target
${MODULE_NAME})
if [ -z "${BUILT_JAR}" ]; then
echo "Couldn't find module '${MODULE_NAME}' jar." >&2
- read -p "Do you want me to run \`mvn package -DskiptTests\` for you ? "
answer
+ read -p "Do you want me to run \`mvn package -DskipTests -Dstream\` for
you ? (y|n) " answer
case "${answer:0:1}" in
y|Y )
- mvn package -DskipTests -Dstream
+ mkdir -p ${BK_HOME}/logs
+ output="${BK_HOME}/logs/build.out"
+ echo "see output at ${output} for the progress ..." >&2
+ mvn package -DskipTests -Dstream &> ${output}
;;
* )
exit 1
@@ -182,8 +214,12 @@ add_maven_deps_to_classpath() {
# and cache it. Save the file into our target dir so a mvn clean will get
# clean it up and force us create a new one.
f="${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt"
+ output="${BK_HOME}/${MODULE_PATH}/target/build_classpath.out"
if [ ! -f ${f} ]; then
- ${MVN} -f "${BK_HOME}/${MODULE_PATH}/pom.xml" -Dstream
dependency:build-classpath -Dmdep.outputFile="target/cached_classpath.txt" &>
/dev/null
+ echo "the classpath of module '${MODULE_PATH}' is not found, generating it
..." >&2
+ echo "see output at ${output} for the progress ..." >&2
+ ${MVN} -f "${BK_HOME}/${MODULE_PATH}/pom.xml" -Dstream
dependency:build-classpath -Dmdep.outputFile="target/cached_classpath.txt" &>
${output}
+ echo "the classpath of module '${MODULE_PATH}' is generated at '${f}'." >&2
fi
}
@@ -249,3 +285,47 @@ build_cli_logging_opts() {
build_bookie_opts() {
echo "-Djava.net.preferIPv4Stack=true"
}
+
+find_table_service() {
+ BOOKIE_CONF_TO_CHECK=$1
+ SERVICE_COMMAND=$2
+
+ # check if it is a released binary
+ IS_RELEASED_BINARY=$(is_released_binary)
+
+ # check if table service is released
+ TABLE_SERVICE_RELEASED="true"
+ if [ "x${IS_RELEASED_BINARY}" == "xtrue" ]; then
+ TABLE_SERVICE_RELEASE_JAR=$(find_module_release_jar
${TABLE_SERVICE_MODULE_NAME})
+ if [ "x${TABLE_SERVICE_RELEASE_JAR}" == "x" ]; then
+ TABLE_SERVICE_RELEASED="false"
+ fi
+ fi
+
+ # check the configuration to see if table service is enabled or not.
+ if [ -z "${ENABLE_TABLE_SERVICE}" ]; then
+ # mask exit code if the configuration file doesn't contain
`StreamStorageLifecycleComponent`
+ TABLE_SERVICE_SETTING=$(grep StreamStorageLifecycleComponent
${BOOKIE_CONF_TO_CHECK} | cat)
+ if [[ "${TABLE_SERVICE_SETTING}" =~ ^extraServerComponents.* ]]; then
+ if [ "x${TABLE_SERVICE_RELEASED}" == "xfalse" ]; then
+ echo "The release binary is built without table service. Please
disable \`StreamStorageLifecycleComponent\` in your bookie configuration at
'${BOOKIE_CONF_TO_CHECK}'."
+ return
+ fi
+ ENABLE_TABLE_SERVICE="true"
+ fi
+ fi
+
+ # standalone only run
+ if [ \( "x${SERVICE_COMMAND}" == "xstandalone" \) -a \(
"x${TABLE_SERVICE_RELEASED}" == "xfalse" \) ]; then
+ echo "The release binary is built without table service. Use \`localbookie
<n>\` instead of \`standalone\` for local development."
+ return
+ fi
+
+ if [ \( "x${SERVICE_COMMAND}" == "xstandalone" \) -o \(
"x${ENABLE_TABLE_SERVICE}" == "xtrue" \) ]; then
+ echo "true"
+ return
+ else
+ echo "false"
+ return
+ fi
+}