Skip to content

Commit

Permalink
Switch required Java version to 21
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo committed Oct 17, 2023
1 parent b0ec383 commit 8d7088c
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 56 deletions.
6 changes: 4 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Verify checked out commits and setup Java"
inputs:
java-version:
description: "Java version to setup"
default: 17
default: 21
cache:
description: "Cache Maven repo (true/false/restore)"
default: true
Expand Down Expand Up @@ -50,7 +50,9 @@ runs:
if: ${{ format('{0}', inputs.cache) == 'true' }}
uses: actions/cache@v3
with:
path: ~/.m2/repository
path: |
~/.m2/repository
/tmp/pt_java_downloads
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ env:
# used by actions/cache to retry the download after this time: https://github.com/actions/cache/blob/main/workarounds.md#cache-segment-restore-timeout
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5
CI_SKIP_SECRETS_PRESENCE_CHECKS: ${{ secrets.CI_SKIP_SECRETS_PRESENCE_CHECKS }}
PTL_TMP_DOWNLOAD_PATH: /tmp/pt_java_downloads

# Cancel previous PR builds.
concurrency:
Expand All @@ -56,7 +57,6 @@ jobs:
fail-fast: false
matrix:
java-version:
- 17
- 21
timeout-minutes: 45
steps:
Expand Down Expand Up @@ -571,7 +571,6 @@ jobs:
- lib/trino-filesystem-s3
- lib/trino-hdfs
- { modules: core/trino-main }
- { modules: core/trino-main, jdk: 21 }
- { modules: lib/trino-filesystem-s3, profile: cloud-tests }
- { modules: lib/trino-filesystem-azure, profile: cloud-tests }
- { modules: plugin/trino-accumulo }
Expand Down Expand Up @@ -642,8 +641,8 @@ jobs:
- uses: ./.github/actions/setup
with:
cache: restore
java-version: ${{ matrix.jdk != '' && matrix.jdk || '17' }}
cleanup-node: ${{ format('{0}', matrix.modules == 'plugin/trino-singlestore') }}
java-version: ${{ matrix.jdk != '' && matrix.jdk || '21' }}
- name: Maven Install
run: |
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
Expand Down
2 changes: 1 addition & 1 deletion core/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
FROM ghcr.io/airlift/jvmkill:latest AS jvmkill

# Use Eclipse Temurin as they have base Docker images for more architectures.
FROM eclipse-temurin:17-jdk
FROM eclipse-temurin:21-jdk

RUN \
set -xeu && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,23 @@
import com.google.common.util.concurrent.ForwardingListeningExecutorService;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import jakarta.annotation.Nullable;

import java.lang.invoke.MethodHandle;
import java.lang.reflect.Method;
import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static com.google.common.base.Throwables.throwIfUnchecked;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.trino.util.Reflection.methodHandle;
import static java.util.Objects.requireNonNull;

public class DecoratingListeningExecutorService
extends ForwardingListeningExecutorService
implements ListeningExecutorService
{
// TODO remove after requiring Java 19+ for runtime.
private static final @Nullable MethodHandle CLOSE_METHOD;

static {
Method closeMethod;
try {
closeMethod = ExecutorService.class.getMethod("close");
}
catch (NoSuchMethodException e) {
closeMethod = null;
}
CLOSE_METHOD = closeMethod != null
? methodHandle(closeMethod)
: null;
}

private final ListeningExecutorService delegate;
private final TaskDecorator decorator;

Expand Down Expand Up @@ -194,21 +172,10 @@ public boolean awaitTermination(Duration duration)
return super.awaitTermination(duration);
}

// TODO This is temporary, until Guava's ForwardingExecutorService has the method in their interface. See https://github.com/google/guava/issues/6296
//@Override
@Override
public void close()
{
if (CLOSE_METHOD == null) {
throw new UnsupportedOperationException("ExecutorService.close has close() method since Java 19. " +
"The DecoratingListeningExecutorService supports the method only when run with Java 19 runtime.");
}
try {
CLOSE_METHOD.invoke(delegate());
}
catch (Throwable e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
delegate.close();
}

public interface TaskDecorator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ else if ("Mac OS X".equals(osName)) {

private static void verifyJavaVersion()
{
Version required = Version.parse("17.0.3");

Version required = Version.parse("21");
if (Runtime.version().compareTo(required) < 0) {
failRequirement("Trino requires Java %s at minimum (found %s)", required, Runtime.version());
}
Expand Down
10 changes: 5 additions & 5 deletions core/trino-server-rpm/src/main/rpm/preinstall
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ check_if_correct_java_version() {
# candidate for JAVA_HOME).
JAVA_VERSION=$(java_version "$1")
JAVA_MAJOR=$(echo "$JAVA_VERSION" | cut -d'.' -f1)
if [ "$JAVA_MAJOR" -ge "17" ]; then
if [ "$JAVA_MAJOR" -ge "21" ]; then
echo "$1" >/tmp/trino-rpm-install-java-home
return 0
else
Expand All @@ -34,8 +34,8 @@ check_if_correct_java_version() {
if ! check_if_correct_java_version "$JAVA_HOME"; then
java_found=false
for candidate in \
/usr/lib/jvm/java-17-* \
/usr/lib/jvm/zulu-17 \
/usr/lib/jvm/java-21-* \
/usr/lib/jvm/zulu-21 \
/usr/lib/jvm/default-java \
/usr/java/default \
/ \
Expand All @@ -55,9 +55,9 @@ if [ "$java_found" = false ]; then
+======================================================================+
| Error: Required Java version could not be found |
+----------------------------------------------------------------------+
| Please install JDK 17. On RHEL/CentOS, use java-17-openjdk-devel. |
| Please install JDK 21. On RHEL/CentOS, use java-21-openjdk-devel. |
| |
| You can also download an OpenJDK 17 build, such as Zulu Community: |
| You can also download an OpenJDK 21 build, such as Zulu Community: |
| >>> https://www.azul.com/downloads/zulu-community/ <<< |
| |
| NOTE: This script will attempt to find Java whether you install |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@
public class ServerIT
{
private static final String BASE_IMAGE_PREFIX = "eclipse-temurin:";
private static final String BASE_IMAGE_SUFFIX = "-jre-centos7";
private static final String BASE_IMAGE_SUFFIX = "-jre-ubi9-minimal";

@Test(dataProvider = "rpmJavaTestDataProvider")
public void testInstall(String rpmHostPath, String javaVersion)
{
String rpm = "/" + new File(rpmHostPath).getName();
String command = "" +
// install required dependencies that are missing in UBI9-minimal
"microdnf install -y python sudo\n" +
// install RPM
"yum localinstall -q -y " + rpm + "\n" +
"rpm -i " + rpm + "\n" +
// create Hive catalog file
"mkdir /etc/trino/catalog\n" +
"echo CONFIG_ENV[HMS_PORT]=9083 >> /etc/trino/env.sh\n" +
Expand Down Expand Up @@ -93,8 +95,10 @@ public void testUninstall(String rpmHostPath, String javaVersion)
{
String rpm = "/" + new File(rpmHostPath).getName();
String installAndStartTrino = "" +
// install required dependencies that are missing in UBI9-minimal
"microdnf install -y python sudo\n" +
// install RPM
"yum localinstall -q -y " + rpm + "\n" +
"rpm -i " + rpm + "\n" +
"/etc/init.d/trino start\n" +
// allow tail to work with Docker's non-local file system
"tail ---disable-inotify -F /var/log/trino/server.log\n";
Expand Down Expand Up @@ -123,8 +127,7 @@ public static Object[][] rpmJavaTestDataProvider()
{
String rpmHostPath = requireNonNull(System.getProperty("rpm"), "rpm is null");
return new Object[][]{
{rpmHostPath, "17"},
{rpmHostPath, "19"}};
{rpmHostPath, "21"}};
}

private static void assertPathDeleted(GenericContainer<?> container, String path)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<air.check.skip-pmd>true</air.check.skip-pmd>
<air.check.skip-jacoco>true</air.check.skip-jacoco>

<project.build.targetJdk>17</project.build.targetJdk>
<project.build.targetJdk>21</project.build.targetJdk>
<air.java.version>17.0.4</air.java.version>
<air.modernizer.java-version>8</air.modernizer.java-version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import static com.google.common.base.Preconditions.checkArgument;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.COORDINATOR;
import static io.trino.tests.product.launcher.env.jdk.BuiltInJdkProvider.BUILT_IN_NAME;
import static java.util.Locale.ENGLISH;
import static picocli.CommandLine.Option;

Expand Down Expand Up @@ -58,7 +57,7 @@ public final class EnvironmentOptions
public String launcherBin;

@Option(names = "--trino-jdk-version", paramLabel = "<trino-jdk-version>", description = "JDK to use for running Trino " + DEFAULT_VALUE)
public String jdkProvider = BUILT_IN_NAME;
public String jdkProvider = "temurin21";

@Option(names = "--jdk-tmp-download-path", paramLabel = "<jdk-tmp-download-path>", defaultValue = "${env:PTL_TMP_DOWNLOAD_PATH:-${sys:java.io.tmpdir}/ptl-tmp-download}", description = "Path to use to download JDK distributions " + DEFAULT_VALUE)
@Nullable
Expand Down

0 comments on commit 8d7088c

Please sign in to comment.