-
Notifications
You must be signed in to change notification settings - Fork 1k
/
maxwell-benchmark
executable file
·104 lines (87 loc) · 2.51 KB
/
maxwell-benchmark
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
99
100
101
102
103
104
#!/bin/bash
set -e
actual_dir=$0
if [ -n "$(LC_ALL=C type -t realpath)" ];
then
actual_dir=`realpath "$actual_dir"`
fi
base_dir="$(dirname "$actual_dir")/.."
lib_dir="$base_dir/lib"
lib_dir_development="$base_dir/target/lib"
if [ ! -e "$lib_dir" -a -e "$lib_dir_development" ]; then
lib_dir="$lib_dir_development"
CLASSPATH="$CLASSPATH:$base_dir/target/classes:$base_dir/target/test-classes:$base_dir/target/lib"
fi
CLASSPATH="$CLASSPATH:$lib_dir/*"
KAFKA_VERSION="1.0.0"
function use_kafka() {
wanted="$1"
# disambiguate versions into the latest,
# e.g. asking for 0.10 means you want the
# latest 0.10.x release
case "$wanted" in
0.11)
KAFKA_VERSION=0.11.0.1
;;
0.10)
KAFKA_VERSION=0.10.2.1
;;
*)
KAFKA_VERSION="$wanted"
;;
esac
}
for key in "$@"
do
case "$key" in
--kafka_version)
use_kafka "$2"
;;
--kafka_version=*)
use_kafka "${key#*=}"
;;
--daemon)
DAEMON_MODE="true"
DAEMON_NAME="MaxwellDaemon"
;;
esac
done
if [ "x$DAEMON_MODE" = "xtrue" ]; then
# Log directory to use
if [ "x$LOG_DIR" = "x" ]; then
LOG_DIR="$base_dir/logs"
fi
# Create logs directory
if [ ! -d "$LOG_DIR" ]; then
mkdir -p "$LOG_DIR"
fi
# Console output file when maxwell runs as a daemon
CONSOLE_OUTPUT_FILE=$LOG_DIR/$DAEMON_NAME.out
echo "Redirecting STDOUT to $CONSOLE_OUTPUT_FILE"
fi
kafka_client_dir="$lib_dir/kafka-clients"
kafka_client_jar="$(ls -1 "$kafka_client_dir/kafka-clients-$KAFKA_VERSION"*.jar 2>/dev/null || true)"
if [ -z "$kafka_client_jar" -o "$(echo "$kafka_client_jar" | wc -l)" -gt 1 ]; then
if [ -z "$kafka_client_jar" ]; then
echo "Error: No matches for kafka version: $KAFKA_VERSION"
else
echo "Error: Multiple matches for kafka version: $KAFKA_VERSION"
fi
echo "Supported versions:"
ls -1 "$kafka_client_dir" | sed -e 's/^kafka-clients-/ - /' -e 's/\.jar$//'
exit 1
else
echo "Using kafka version: $KAFKA_VERSION"
CLASSPATH="$CLASSPATH:$kafka_client_jar"
fi
if [ -z "$JAVA_HOME" ]; then
JAVA="java"
else
JAVA="$JAVA_HOME/bin/java"
fi
# Launch mode
if [ "x$DAEMON_MODE" = "xtrue" ]; then
nohup $JAVA $JAVA_OPTS -Dfile.encoding=UTF-8 -Dlog4j.shutdownCallbackRegistry=com.djdch.log4j.StaticShutdownCallbackRegistry -cp $CLASSPATH com.zendesk.maxwell.benchmark.MaxwellBenchmark "$@" > "$CONSOLE_OUTPUT_FILE" 2>&1 < /dev/null &
else
exec $JAVA $JAVA_OPTS -Dfile.encoding=UTF-8 -Dlog4j.shutdownCallbackRegistry=com.djdch.log4j.StaticShutdownCallbackRegistry -cp $CLASSPATH com.zendesk.maxwell.benchmark.MaxwellBenchmark "$@"
fi