/
geowave-tools.sh
executable file
·87 lines (76 loc) · 3.44 KB
/
geowave-tools.sh
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
#-------------------------------------------------------------------------------
# Copyright (c) 2013-2017 Contributors to the Eclipse Foundation
#
# See the NOTICE file distributed with this work for additional
# information regarding copyright ownership.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License,
# Version 2.0 which accompanies this distribution and is available at
# http://www.apache.org/licenses/LICENSE-2.0.txt
#-------------------------------------------------------------------------------
#!/bin/bash
# Which java to use
if [ -z "$JAVA_HOME" ]; then
JAVA="java"
else
JAVA="$JAVA_HOME/bin/java"
fi
# Setting up Hadoop env
if [ -z "$HADOOP_HOME" ]; then
VENDOR_VERSION=$( cat $GEOWAVE_TOOLS_HOME/geowave-tools-build.properties | grep -oi "vendor.version=\w*" | sed "s/vendor.version=//g")
if [[ $VENDOR_VERSION == apache ]]; then
export HADOOP_HOME=/usr/lib/hadoop
elif [[ $VENDOR_VERSION == hdp* ]]; then
export HADOOP_HOME=/usr/hdp/current/hadoop-client
export HDP_VERSION=$(hdp-select| grep hadoop-hdfs-namenode| sed "s/hadoop-hdfs-namenode - //g")
export GEOWAVE_TOOL_JAVA_OPT="$GEOWAVE_TOOL_JAVA_OPT -Dhdp.version=${HDP_VERSION}"
elif [[ $VENDOR_VERSION == cdh* ]]; then
export HADOOP_HOME=/usr/lib/hadoop
else
echo "Unknown Hadoop Distribution. Set env variable HADOOP_HOME."
fi
fi
# set up HADOOP specific env only if HADOOP is installed
if [ -n "${HADOOP_HOME}" ] && [ -d "${HADOOP_HOME}" ]; then
. $HADOOP_HOME/libexec/hadoop-config.sh
HADOOP_CLASSPATH=""
for i in $(echo $CLASSPATH | sed "s/:/ /g")
do
if [[ "$i" != *log4j-slf4j-impl*.jar && "$i" != *slf4j-log4j*.jar ]]; then
HADOOP_CLASSPATH=${HADOOP_CLASSPATH}:$i
fi
done
fi
CLASSPATH=${HADOOP_CLASSPATH}
# Setting up Spark env
if [ -z "$SPARK_HOME" ]; then
VENDOR_VERSION=$( cat $GEOWAVE_TOOLS_HOME/geowave-tools-build.properties | grep -oi "vendor.version=\w*" | sed "s/vendor.version=//g")
if [[ $VENDOR_VERSION == apache ]]; then
export SPARK_HOME=/usr/lib/spark
elif [[ $VENDOR_VERSION == hdp* ]]; then
export SPARK_HOME=/usr/hdp/current/spark2-client
elif [[ $VENDOR_VERSION == cdh* ]]; then
export SPARK_HOME=/usr/lib/spark
else
echo "Unknown Spark Distribution. Set env variable SPARK_HOME."
fi
fi
# Ensure both our tools jar and anything in the plugins directory is on the classpath
# Add Spark jars to class path only if SPARK_HOME directory exists
if [ -n "${SPARK_HOME}" ] && [ -d "${SPARK_HOME}" ]; then
. "${SPARK_HOME}"/bin/load-spark-env.sh
SPARK_CLASSPATH=""
for i in ${SPARK_HOME}/jars/*.jar
do
if [[ "$i" != *log4j-slf4j-impl*.jar && "$i" != *guava*.jar && "$i" != *slf4j-log4j*.jar ]]; then
SPARK_CLASSPATH=${SPARK_CLASSPATH}:$i
fi
done
CLASSPATH="${SPARK_HOME}/conf:${SPARK_CLASSPATH}:$GEOWAVE_TOOLS_HOME/$GEOWAVE_TOOLS_JAR:$GEOWAVE_TOOLS_HOME/plugins/*:${CLASSPATH}"
else
CLASSPATH="$GEOWAVE_TOOLS_HOME/$GEOWAVE_TOOLS_JAR:$GEOWAVE_TOOLS_HOME/plugins/*:${CLASSPATH}"
fi
# Define log4j properties file in jar call, to reduce log spam.
LOG_PROPERTIES="-Djava.util.logging.config.file=jul-geowave-cli.properties -Dgeowave.home=$GEOWAVE_TOOLS_HOME"
# Using -cp and the classname instead of -jar because Java 7 and below fail to auto-launch jars with more than 65k files
exec $JAVA $GEOWAVE_TOOL_JAVA_OPT $LOG_PROPERTIES -cp $CLASSPATH org.locationtech.geowave.core.cli.GeoWaveMain "$@"