Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the default_value of JAVA_HOME for running RPS #1206

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems no /usr/java/default existed in rps.properties?
I refer here:https://github.com/apache/incubator-hawq/blob/master/ranger-plugin/conf/rps.properties

Is there something wrong?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Forgot to commit the other 2 files :-(

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