Skip to content

Commit

Permalink
HAWQ-1415. Set the default_value of JAVA_HOME for running RPS (closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
ljainpivotalio authored and Ed Espino committed Mar 29, 2017
1 parent fe6c0e9 commit dc41e4c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ranger-plugin/conf/rps.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ RPS_HEAP_SIZE=128m

# use CATALINA_HOME in default and use /usr/lib/bigtop-tomcat if CATALINA_HOME not set
CATALINA_HOME=${CATALINA_HOME:-/usr/lib/bigtop-tomcat}

# use JAVA_HOME in default and use /usr/java/default if JAVA_HOME not set
JAVA_HOME=${JAVA_HOME:-/usr/java/default}
25 changes: 24 additions & 1 deletion ranger-plugin/scripts/enable-ranger-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function validate_params() {
get_hawq_password
echo "RANGER URL = ${RANGER_URL}"
echo "RANGER User = ${RANGER_USER}"
echo "RANGER Password = $(mask ${RANGER_PASSWORD})"
echo "RANGER Password = $(mask ${RANGER_PASSWORD})"
echo "HAWQ HOST = ${HAWQ_HOST}"
echo "HAWQ PORT = ${HAWQ_PORT}"
echo "HAWQ User = ${HAWQ_USER}"
Expand Down Expand Up @@ -211,6 +211,28 @@ function update_ranger_url() {
echo "Updated POLICY_MGR_URL to ${policy_mgr_url} in ${prop_file}"
}

function update_java_home() {
local jdk64="/usr/jdk64"
local java_sdk="/etc/alternatives/java_sdk"

if [[ -d ${jdk64} ]]; then
local DIR_NAME=$(ls ${jdk64} | sort -r | head -1)
if [[ ${DIR_NAME} ]]; then
JAVA_HOME_DIR="${jdk64}/${DIR_NAME}"
fi
elif [[ -d ${java_sdk} ]]; then
JAVA_HOME_DIR="${java_sdk}"
fi

if [[ ${JAVA_HOME_DIR} ]]; then
local prop_file=$(dirname ${SCRIPT_DIR})/etc/rps.properties
sed -i -e "s|/usr/java/default|${JAVA_HOME_DIR}|g" ${prop_file}
echo "Updated default value of JAVA_HOME to ${JAVA_HOME_DIR} in ${prop_file}"
elif [[ ! ${JAVA_HOME} ]]; then
echo "Unable to locate JAVA_HOME on this machine. Please modify the default value of JAVA_HOME in ${prop_file}."
fi
}

main() {
if [[ $# -lt 1 ]]; then
usage
Expand All @@ -221,5 +243,6 @@ main() {
create_hawq_service_definition
create_hawq_service_instance
update_ranger_url
update_java_home
}
main "$@"
1 change: 1 addition & 0 deletions ranger-plugin/scripts/rps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ BASEDIR=$( dirname ${CWDIR} )
# read properties from the file
source ${BASEDIR}/etc/rps.properties

export JAVA_HOME
export CATALINA_HOME
export CATALINA_BASE=${BASEDIR}/plugin-service
export CATALINA_PID=${CATALINA_BASE}/work/rps.pid
Expand Down

0 comments on commit dc41e4c

Please sign in to comment.