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

Allow to install Presto RPM with Java 11 #2057

Merged
merged 1 commit into from Nov 21, 2019
Merged
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
6 changes: 3 additions & 3 deletions presto-server-rpm/src/main/resources/dist/etc/init.d/presto
Expand Up @@ -33,12 +33,12 @@ source /etc/presto/env.sh

start () {
echo "Starting ${SERVICE_NAME} "
if [ -z "$JAVA8_HOME" ]
if [ -z "$PRESTO_JAVA_HOME" ]
then
echo "Warning: No value found for JAVA8_HOME. Default Java will be used."
echo "Warning: No value found for $PRESTO_JAVA_HOME. Default Java will be used."
sudo -u $SERVICE_USER /usr/lib/presto/bin/launcher start "${CONFIGURATION[@]}"
else
sudo -u $SERVICE_USER PATH=${JAVA8_HOME}/bin:$PATH /usr/lib/presto/bin/launcher start "${CONFIGURATION[@]}"
sudo -u $SERVICE_USER PATH=${$PRESTO_JAVA_HOME}/bin:$PATH /usr/lib/presto/bin/launcher start "${CONFIGURATION[@]}"
fi
return $?
}
Expand Down
11 changes: 8 additions & 3 deletions presto-server-rpm/src/main/rpm/preinstall
Expand Up @@ -22,18 +22,23 @@ check_if_correct_java_version() {
# candidate for JAVA_HOME).
JAVA_VERSION=$(java_version "$1")
JAVA_UPDATE=$(echo $JAVA_VERSION | cut -d'_' -f2)
if [[ ("$JAVA_VERSION" > "1.8") && ($JAVA_UPDATE -ge 161) ]]; then
echo "JAVA8_HOME=$1" > /tmp/presto_env.sh
JAVA_MAJOR=$(echo $JAVA_VERSION | cut -d'.' -f1)
if [[ ("$JAVA_MAJOR" -ge "11") ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

what about other versions? Can we make the mechanism generic?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is quite generic for example 12 > 11. However then env variable JAVA11_HOME has unfortunate name.

echo "$PRESTO_JAVA_HOME=$1" > /tmp/presto_env.sh
return 0
elif [[ ("$JAVA_VERSION" > "1.8") && ($JAVA_UPDATE -ge 161) ]]; then
echo "$PRESTO_JAVA_HOME=$1" > /tmp/presto_env.sh
return 0
else
return 1
fi
}

# if Java version of $JAVA_HOME is not 1.8 update 161 (8u161) and is not Oracle Java, then try to find it again below
if ! check_if_correct_java_version "$JAVA8_HOME" && ! check_if_correct_java_version "$JAVA_HOME"; then
if ! check_if_correct_java_version "$PRESTO_JAVA_HOME" && ! check_if_correct_java_version "$JAVA_HOME"; then
java_found=false
for candidate in \
/usr/lib/jvm/java-11-* \
/usr/lib/jvm/jdk1.8* \
/usr/lib/jvm/jre1.8* \
/usr/lib/jvm/java-8-oracle* \
Expand Down
Expand Up @@ -36,12 +36,20 @@ public class ServerIT
{
@Parameters("rpm")
@Test
public void testServer(String rpm)
public void testWithJava8(String rpm)
throws Exception
{
testServer("prestodev/centos7-oj8", rpm);
}

@Parameters("rpm")
@Test
public void testWithJava11(String rpm)
throws Exception
{
testServer("prestodev/centos7-oj11", rpm);
}

private static void testServer(String baseImage, String rpmHostPath)
throws Exception
{
Expand Down