-
Notifications
You must be signed in to change notification settings - Fork 380
/
Copy pathceleborn-ratis
executable file
·98 lines (83 loc) · 3.21 KB
/
celeborn-ratis
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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
#
# 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.
function printUsage {
echo "Usage: celeborn-ratis COMMAND [GENERIC_COMMAND_OPTIONS] [COMMAND_ARGS]"
echo
echo "COMMAND is one of:"
echo -e " sh \t Command line tool for Celeborn ratis"
echo
echo "GENERIC_COMMAND_OPTIONS supports:"
echo -e " -D<property=value>\t Use a value for a given ratis-shell property"
echo
echo "Commands print help when invoked without parameters."
}
function runJavaClass {
CLASS_ARGS=()
for arg in "$@"; do
case "${arg}" in
-D* | -X* | -agentlib* | -javaagent*)
CELEBORN_RATIS_SHELL_JAVA_OPTS+=" ${arg}" ;;
*)
CLASS_ARGS+=("${arg}")
esac
done
"${JAVA}" -cp "${CLASSPATH}" -XX:+IgnoreUnrecognizedVMOptions ${CELEBORN_RATIS_SHELL_JAVA_OPTS} "${CLASS}" ${PARAMETER} "${CLASS_ARGS[@]}"
}
function main {
if [[ $# == 0 ]]; then
printUsage
exit 1
fi
COMMAND=$1
shift
local CELEBORN_RATIS_SHELL_CLASSPATH
# load master jars since all ratis related in master
while read -d '' -r jarfile ; do
if [[ "$CELEBORN_RATIS_SHELL_CLASSPATH" == "" ]]; then
CELEBORN_RATIS_SHELL_CLASSPATH="$jarfile";
else
CELEBORN_RATIS_SHELL_CLASSPATH="$CELEBORN_RATIS_SHELL_CLASSPATH":"$jarfile"
fi
done < <(find "$CELEBORN_HOME/master-jars" ! -type d -name '*.jar' -print0 | sort -z)
CELEBORN_RATIS_SHELL_CLIENT_CLASSPATH="${CELEBORN_CONF_DIR}/:${CELEBORN_RATIS_SHELL_CLASSPATH}"
if [ ! -f "${CELEBORN_CONF_DIR}/ratis-log4j.properties" ]; then
echo "${CELEBORN_CONF_DIR}/ratis-log4j.properties not exists!" >&2
fi
CELEBORN_RATIS_SHELL_JAVA_OPTS+=" -Dratis.shell.logs.dir=${CELEBORN_LOG_DIR}"
CELEBORN_RATIS_SHELL_JAVA_OPTS+=" -Dlog4j.configuration=file:${CELEBORN_CONF_DIR}/ratis-log4j.properties"
CELEBORN_RATIS_SHELL_JAVA_OPTS+=" -Dorg.apache.jasper.compiler.disablejsr199=true"
CELEBORN_RATIS_SHELL_JAVA_OPTS+=" -Djava.net.preferIPv4Stack=true"
CELEBORN_RATIS_SHELL_JAVA_OPTS+=" -Dorg.apache.ratis.thirdparty.io.netty.allocator.useCacheForAllThreads=false"
PARAMETER=""
case ${COMMAND} in
"sh")
CLASS="org.apache.ratis.shell.cli.sh.RatisShell"
CLASSPATH=${CELEBORN_RATIS_SHELL_CLIENT_CLASSPATH}
runJavaClass "$@"
;;
*)
echo "Unsupported command ${COMMAND}" >&2
printUsage
exit 1
;;
esac
}
# Load Celeborn related env
if [ -z "${CELEBORN_HOME}" ]; then
export CELEBORN_HOME="$(cd "`dirname "$0"`"/..; pwd)"
fi
. "${CELEBORN_HOME}/sbin/load-celeborn-env.sh"
main "$@"