forked from OpenTSDB/opentsdb
-
Notifications
You must be signed in to change notification settings - Fork 8
/
tsdb.in
88 lines (83 loc) · 2.5 KB
/
tsdb.in
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
#!/bin/bash
set -e
me=`basename "$0"`
mydir=`dirname "$0"`
# Either:
# abs_srcdir and abs_builddir are set: we're running in a dev tree
# or pkgdatadir is set: we've been installed, we respect that.
abs_srcdir='@abs_srcdir@'
abs_builddir='@abs_builddir@'
pkgdatadir='@pkgdatadir@'
# Either we've been installed and pkgdatadir exists, or we haven't been
# installed and abs_srcdir / abs_builddir aren't empty.
test -d "$pkgdatadir" || test -n "$abs_srcdir$abs_builddir" || {
echo >&2 "$me: Uh-oh, \`$pkgdatadir' doesn't exist, is OpenTSDB properly installed?"
exit 1
}
if test -n "$pkgdatadir"; then
localdir="$pkgdatadir"
for jar in "$pkgdatadir"/*.jar; do
CLASSPATH="$CLASSPATH:$jar"
done
# Add pkgdatadir itself so we can find logback.xml
CLASSPATH="$CLASSPATH:$pkgdatadir"
else
localdir="$abs_builddir"
# If we're running out of the build tree, it's especially important that we
# know exactly what jars we need to build the CLASSPATH. Otherwise people
# cannot easily pick up new dependencies as we might mix multiple versions
# of the same dependencies on the CLASSPATH, which is bad. Looking for a
# specific version of each jar prevents this problem.
# TODO(tsuna): Once we jarjar all the dependencies together, this will no
# longer be an issue. See issue #23.
for jar in `make -C "$abs_builddir" printdeps | sed '/third_party.*jar/!d'`; do
for dir in "$abs_builddir" "$abs_srcdir"; do
test -f "$dir/$jar" && CLASSPATH="$CLASSPATH:$dir/$jar" && continue 2
done
echo >&2 "$me: error: Couldn't find \`$jar' either under \`$abs_builddir' or \`$abs_srcdir'."
exit 2
done
# Add the src dir so we can find logback.xml
CLASSPATH="$CLASSPATH:$abs_srcdir/src"
fi
# Remove any leading colon.
CLASSPATH="${CLASSPATH#:}"
usage() {
echo >&2 "usage: $me <command> [args]"
echo 'Valid commands: fsck, import, mkmetric, query, tsd, scan, uid'
exit 1
}
case $1 in
(fsck)
MAINCLASS=Fsck
;;
(import)
MAINCLASS=TextImporter
;;
(mkmetric)
shift
set uid assign metrics "$@"
MAINCLASS=UidManager
;;
(query)
MAINCLASS=CliQuery
;;
(tsd)
MAINCLASS=TSDMain
;;
(scan)
MAINCLASS=DumpSeries
;;
(uid)
MAINCLASS=UidManager
;;
(*)
echo >&2 "$me: error: unknown command '$1'"
usage
;;
esac
shift
JAVA=${JAVA-'java'}
JVMARGS=${JVMARGS-'-enableassertions -enablesystemassertions'}
test -r "$localdir/tsdb.local" && . "$localdir/tsdb.local"
exec $JAVA $JVMARGS -classpath "$CLASSPATH" net.opentsdb.tools.$MAINCLASS "$@"