forked from flumebase/flumebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flumebase
executable file
·106 lines (89 loc) · 3.03 KB
/
flumebase
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
105
#!/bin/bash
bin=`dirname $0`
bin=`cd "${bin}" && pwd`
projectroot=`cd "${bin}/.." && pwd`
LIB_DIR="${projectroot}/lib"
MVN_TARGET_DIR="${projectroot}/target"
MVN_BUILD_DEPS_DIR="${MVN_TARGET_DIR}/dependency"
# CDH installation default
FLUME_HOME=${FLUME_HOME:-/usr/lib/flume}
function usage() {
echo "Usage: flumebase <command> [args...]"
echo "Commands include:"
echo " shell Start the FlumeBase shell"
echo " server Start a server to run background queries"
echo " version Print FlumeBase version information and exit"
}
# Format: flumebase <command> [args...]
action="$1"
shift
if [ -z "$action" ]; then
usage
exit 0
elif [ "$action" == "shell" ]; then
FLUMEBASE_MAIN_CLASS=com.odiago.flumebase.client.CmdLineClient
elif [ "$action" == "server" ]; then
FLUMEBASE_MAIN_CLASS=com.odiago.flumebase.server.ServerMain
elif [ "$action" == "version" ]; then
FLUMEBASE_MAIN_CLASS=com.odiago.flumebase.util.VersionInfo
else
echo "Invalid command: $action"
usage
exit 1
fi
FLUMEBASE_CLASSPATH="${FLUMEBASE_CLASSPATH:-}"
FLUMEBASE_OPTS="${FLUMEBASE_OPTS:-}"
FLUMEBASE_CONF_DIR=${FLUMEBASE_CONF_DIR:-"${projectroot}/etc"}
function add_to_classpath() {
dir=$1
if [ ! -d "${dir}" ]; then
return 0
fi
for jar in `ls "${dir}"`; do
if [ -z "$FLUMEBASE_CLASSPATH" ]; then
FLUMEBASE_CLASSPATH="${dir}/${jar}"
else
FLUMEBASE_CLASSPATH="${FLUMEBASE_CLASSPATH}:${dir}/${jar}"
fi
done
}
# If no lib dir exists and no dependency dir exists, then
# try to use mvn to retrieve dependencies.
if [ \( ! -d "${LIB_DIR}" \) -a \( ! -d "${MVN_BUILD_DEPS_DIR}" \) ]; then
which mvn 2>&1 >/dev/null
ret=$?
if [ "${ret}" == 0 ]; then
pushd "${projectroot}"
echo "Retrieving dependencies via mvn"
mvn dependency:copy-dependencies
popd
else
echo "WARNING: Couldn't find any dependencies. mvn doesn't seem to be"
echo "installed, so I don't know how to get them, either. This will"
echo "probably explode."
fi
fi
add_to_classpath "${MVN_BUILD_DEPS_DIR}"
add_to_classpath "${LIB_DIR}"
# Put Flume (and via this, Hadoop) directly on the classpath; we don't redistribute
# Flume with FlumeBase; it's marked as a 'provided' dependency.
if [ ! -z "${FLUME_HOME}" -a -d "${FLUME_HOME}/lib" ]; then
add_to_classpath "${FLUME_HOME}/lib"
else
echo "Warning: Couldn't find Flume installation. Make sure \$FLUME_HOME is set."
exit 1
fi
# If pulling Flume from a development repository, its jar is in build/, not lib/.
if [ ! -z "${FLUME_HOME}" -a -d "${FLUME_HOME}/build" ]; then
flumejar=`ls -1 ${FLUME_HOME}/build/flume-*-core.jar | head -1`
FLUMEBASE_CLASSPATH="${FLUMEBASE_CLASSPATH}:${flumejar}"
fi
if [ -d "${MVN_TARGET_DIR}/classes" ]; then
# If there's a target/classes/ dir, then we want to put this ahead of any
# jars on the classpath; use the most recently compiled bits.
FLUMEBASE_CLASSPATH="${MVN_TARGET_DIR}/classes:$FLUMEBASE_CLASSPATH"
fi
exec java -cp "${FLUMEBASE_CLASSPATH}" \
-Dflumebase.conf.dir="${FLUMEBASE_CONF_DIR}" \
$FLUMEBASE_OPTS \
"${FLUMEBASE_MAIN_CLASS}" "$@"