diff --git a/bin/cassandra.in.sh b/bin/cassandra.in.sh index bc8db76e7ef2..61eed888dc52 100644 --- a/bin/cassandra.in.sh +++ b/bin/cassandra.in.sh @@ -153,7 +153,9 @@ esac # Read user-defined JVM options from jvm-server.options file JVM_OPTS_FILE=$CASSANDRA_CONF/jvm${jvmoptions_variant:--clients}.options -if [ $JAVA_VERSION -ge 17 ] ; then +if [ $JAVA_VERSION -ge 22 ] ; then + JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm22${jvmoptions_variant:--clients}.options +elif [ $JAVA_VERSION -ge 17 ] ; then JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm17${jvmoptions_variant:--clients}.options elif [ $JAVA_VERSION -ge 11 ] ; then JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm11${jvmoptions_variant:--clients}.options diff --git a/build.xml b/build.xml index ee369f704afd..628b11c874e4 100644 --- a/build.xml +++ b/build.xml @@ -38,6 +38,15 @@ + + + + + @@ -196,16 +205,11 @@ - - - - - - - - - - + + + + + -Djdk.attach.allowAttachSelf=true @@ -248,11 +252,81 @@ --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED - - - - - + + + + + + + -XX:+UnlockDiagnosticVMOptions + -Djdk.attach.allowAttachSelf=true + -XX:+UseG1GC + -XX:+ParallelRefProcEnabled + + + -XX:G1RSetUpdatingPauseTimePercent=5 + -XX:MaxGCPauseMillis=100 + + + -XX:-RestrictContended + -XX:+UseThreadPriorities + -XX:+DebugNonSafepoints + -XX:+UseStringDeduplication + -XX:StringTableSize=1000003 + -XX:+PerfDisableSharedMem + -XX:+AlwaysPreTouch + -XX:+UseTLAB + -XX:+ResizeTLAB + -XX:+UseNUMA + + + --add-exports java.base/jdk.internal.misc=ALL-UNNAMED + --add-exports java.base/jdk.internal.perf=ALL-UNNAMED + --add-exports java.base/jdk.internal.ref=ALL-UNNAMED + --add-exports java.base/jdk.internal.util.random=ALL-UNNAMED + --add-exports java.base/sun.nio.ch=ALL-UNNAMED + --add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED + --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED + --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED + --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + --add-exports jdk.naming.dns/com.sun.jndi.dns=java.naming + --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED + + --add-opens java.base/java.io=ALL-UNNAMED + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.lang.module=ALL-UNNAMED + --add-opens java.base/java.lang.ref=ALL-UNNAMED + --add-opens java.base/java.lang.reflect=ALL-UNNAMED + --add-opens java.base/java.math=ALL-UNNAMED + --add-opens java.base/java.net=ALL-UNNAMED + --add-opens java.base/java.nio=ALL-UNNAMED + --add-opens java.base/java.nio.file.spi=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + --add-opens java.base/java.util.concurrent.locks=ALL-UNNAMED + --add-opens java.base/jdk.internal.loader=ALL-UNNAMED + --add-opens java.base/jdk.internal.math=ALL-UNNAMED + --add-opens java.base/jdk.internal.module=ALL-UNNAMED + --add-opens java.base/jdk.internal.ref=ALL-UNNAMED + --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED + --add-opens java.base/jdk.internal.vm=ALL-UNNAMED + --add-opens java.base/sun.nio.ch=ALL-UNNAMED + --add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED + --add-opens jdk.management.jfr/jdk.management.jfr=ALL-UNNAMED + --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED + --add-opens jdk.naming.dns/com.sun.jndi.dns=ALL-UNNAMED + + --add-opens java.base/java.nio.file.attribute=ALL-UNNAMED + + + --add-opens java.base/java.util.concurrent=ALL-UNNAMED + --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED + --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED + + + + + --add-modules jdk.incubator.vector + + + + + + + @@ -291,17 +374,6 @@ - - - - - - - - - - - @@ -344,57 +416,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -406,6 +431,13 @@ + + + + + + + @@ -580,7 +612,7 @@ - + @@ -950,7 +982,7 @@ - + @@ -962,11 +994,11 @@ - + Nashorn's ClassFilter class as any javac modules option is invalid for release 8. --> + + destdir="${build.classes.main}" includeantruntime="false" source="${ant.java.version}" target="${ant.java.version}"> @@ -998,7 +1030,7 @@ @@ -1015,7 +1047,7 @@ @@ -1056,7 +1088,7 @@ @@ -1073,7 +1105,7 @@ @@ -1366,8 +1398,8 @@ debuglevel="${debuglevel}" destdir="${test.classes}" includeantruntime="true" - source="${source.version}" - target="${target.version}" + source="${ant.java.version}" + target="${ant.java.version}" encoding="utf-8"> @@ -1491,19 +1523,19 @@ - + - + - + @@ -2191,13 +2222,13 @@ - - - - + + + + @@ -2213,6 +2244,8 @@ + + @@ -2230,7 +2263,13 @@ ]]> - + + + IDE configuration in .idea/ updated for use with JDK${ant.java.version}. + + In IntelliJ verify that the SDK is ${ant.java.version}, and its path is valid. + This can be verified in 'Project Structure/Project Setting/Project' and 'Project Structure/Platform Setting/SDKs'. + @@ -2329,9 +2368,9 @@ failonerror="true" maxmemory="512m"> - + - + diff --git a/conf/jvm11-server.options b/conf/jvm11-server.options index 5ec7d16e7b8f..4b5eeabc969c 100644 --- a/conf/jvm11-server.options +++ b/conf/jvm11-server.options @@ -92,7 +92,7 @@ # Java 11 (and newer) GC logging options: # See description of https://bugs.openjdk.java.net/browse/JDK-8046148 for details about the syntax # The following is the equivalent to -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10M --Xlog:gc=info,heap*=debug,age*=debug,safepoint=info,promotion*=debug:file=/var/log/cassandra/gc.log:time,uptime,pid,tid,level:filecount=10,filesize=10485760 +# -Xlog:gc=info,heap*=debug,age*=debug,safepoint=info,promotion*=debug:file=/var/log/cassandra/gc.log:time,uptime,pid,tid,level:filecount=10,filesize=10485760 # Notes for Java 8 migration: # diff --git a/conf/jvm17-server.options b/conf/jvm17-server.options index 5055a02c1a5f..e091494707e4 100644 --- a/conf/jvm17-server.options +++ b/conf/jvm17-server.options @@ -89,7 +89,7 @@ # Java 11 (and newer) GC logging options: # See description of https://bugs.openjdk.java.net/browse/JDK-8046148 for details about the syntax # The following is the equivalent to -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10M --Xlog:gc=info,heap*=debug,age*=debug,safepoint=info,promotion*=debug:file=/var/log/cassandra/gc.log:time,uptime,pid,tid,level:filecount=10,filesize=10485760 +# -Xlog:gc=info,heap*=debug,age*=debug,safepoint=info,promotion*=debug:file=/var/log/cassandra/gc.log:time,uptime,pid,tid,level:filecount=10,filesize=10485760 # Notes for Java 8 migration: # diff --git a/conf/jvm22-clients.options b/conf/jvm22-clients.options new file mode 100644 index 000000000000..42ee72e33a67 --- /dev/null +++ b/conf/jvm22-clients.options @@ -0,0 +1,32 @@ +########################################################################### +# jvm22-clients.options # +# # +# See jvm-clients.options. This file is specific for Java 22 and newer. # +########################################################################### + +################### +# JPMS SETTINGS # +################### + +-Djdk.attach.allowAttachSelf=true +--add-exports java.base/jdk.internal.misc=ALL-UNNAMED +--add-exports java.base/jdk.internal.ref=ALL-UNNAMED +--add-exports java.base/sun.nio.ch=ALL-UNNAMED +--add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED +--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED +--add-exports java.rmi/sun.rmi.server=ALL-UNNAMED +--add-exports java.sql/java.sql=ALL-UNNAMED +--add-exports jdk.attach/sun.tools.attach=ALL-UNNAMED + +--add-opens java.base/java.io=ALL-UNNAMED +--add-opens java.base/java.lang.module=ALL-UNNAMED +--add-opens java.base/java.lang.reflect=ALL-UNNAMED +--add-opens java.base/jdk.internal.loader=ALL-UNNAMED +--add-opens java.base/jdk.internal.math=ALL-UNNAMED +--add-opens java.base/jdk.internal.module=ALL-UNNAMED +--add-opens java.base/jdk.internal.ref=ALL-UNNAMED +--add-opens java.base/jdk.internal.reflect=ALL-UNNAMED +--add-opens java.base/sun.nio.ch=ALL-UNNAMED +--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED + +# The newline in the end of file is intentional diff --git a/conf/jvm22-server.options b/conf/jvm22-server.options new file mode 100644 index 000000000000..236ca90f0968 --- /dev/null +++ b/conf/jvm22-server.options @@ -0,0 +1,109 @@ +########################################################################### +# jvm22-server.options # +# # +# See jvm-server.options. This file is specific for Java 22 and newer. # +########################################################################### + +################# +# GC SETTINGS # +################# + +### G1 Settings +## Use the Hotspot garbage-first collector. +-XX:+UseG1GC +-XX:+ParallelRefProcEnabled + +# +## Have the JVM do less remembered set work during STW, instead +## preferring concurrent GC. Reduces p99.9 latency. +-XX:G1RSetUpdatingPauseTimePercent=5 +# +## Main G1GC tunable: lowering the pause target will lower throughput and vise versa. +## 200ms is the JVM default and lowest viable setting +## 1000ms increases throughput. Keep it smaller than the timeouts in cassandra.yaml. +-XX:MaxGCPauseMillis=500 + +## Optional G1 Settings +# Save CPU time on large (>= 16GB) heaps by delaying region scanning +# until the heap is 70% full. The default in Hotspot 8u40 is 40%. +#-XX:InitiatingHeapOccupancyPercent=70 + +# For systems with > 8 cores, the default ParallelGCThreads is 5/8 the number of logical cores. +# Otherwise equal to the number of cores when 8 or less. +# Machines with > 10 cores should try setting these to <= full cores. +#-XX:ParallelGCThreads=16 +# By default, ConcGCThreads is 1/4 of ParallelGCThreads. +# Setting both to the same value can reduce STW durations. +#-XX:ConcGCThreads=16 + + +### JPMS + +-Djdk.attach.allowAttachSelf=true +-Djava.security.manager=allow +--add-exports java.base/jdk.internal.misc=ALL-UNNAMED +--add-exports java.base/jdk.internal.ref=ALL-UNNAMED +--add-exports java.base/jdk.internal.perf=ALL-UNNAMED +--add-exports java.base/sun.nio.ch=ALL-UNNAMED +--add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED +--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED +--add-exports java.rmi/sun.rmi.server=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED +--add-exports jdk.naming.dns/com.sun.jndi.dns=java.naming +--add-exports jdk.unsupported/sun.misc=ALL-UNNAMED + +--add-opens java.base/java.io=ALL-UNNAMED +--add-opens java.base/java.lang.module=ALL-UNNAMED +--add-opens java.base/java.lang=ALL-UNNAMED +--add-opens java.base/java.lang.reflect=ALL-UNNAMED +--add-opens java.base/java.nio.file.spi=ALL-UNNAMED +--add-opens java.base/java.nio=ALL-UNNAMED +--add-opens java.base/java.net=ALL-UNNAMED +--add-opens java.base/java.util=ALL-UNNAMED +--add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED +--add-opens java.base/java.util.concurrent.locks=ALL-UNNAMED +--add-opens java.base/jdk.internal.loader=ALL-UNNAMED +--add-opens java.base/jdk.internal.math=ALL-UNNAMED +--add-opens java.base/jdk.internal.module=ALL-UNNAMED +--add-opens java.base/jdk.internal.ref=ALL-UNNAMED +--add-opens java.base/jdk.internal.reflect=ALL-UNNAMED +--add-opens java.base/jdk.internal.vm=ALL-UNNAMED +--add-opens java.base/sun.nio.ch=ALL-UNNAMED +--add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED +--add-opens jdk.management.jfr/jdk.management.jfr=ALL-UNNAMED +--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED +--add-opens jdk.naming.dns/com.sun.jndi.dns=ALL-UNNAMED + +# required for org.apache.cassandra.Util.getSupportedMTimeGranularity +--add-opens java.base/java.nio.file.attribute=ALL-UNNAMED + +### GC logging options -- uncomment to enable + +# Java 11 (and newer) GC logging options: +# See description of https://bugs.openjdk.java.net/browse/JDK-8046148 for details about the syntax +# The following is the equivalent to -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10M +# -Xlog:gc=info,heap*=debug,age*=debug,safepoint=info,promotion*=debug:file=/var/log/cassandra/gc.log:time,uptime,pid,tid,level:filecount=10,filesize=10485760 + +# Notes for Java 8 migration: +# +# -XX:+PrintGCDetails maps to -Xlog:gc*:... - i.e. add a '*' after "gc" +# -XX:+PrintGCDateStamps maps to decorator 'time' +# +# -XX:+PrintHeapAtGC maps to 'heap' with level 'trace' +# -XX:+PrintTenuringDistribution maps to 'age' with level 'debug' +# -XX:+PrintGCApplicationStoppedTime maps to 'safepoint' with level 'info' +# -XX:+PrintPromotionFailure maps to 'promotion' with level 'trace' +# -XX:PrintFLSStatistics=1 maps to 'freelist' with level 'trace' + +### Netty Options + +# On Java >= 9 Netty requires the io.netty.tryReflectionSetAccessible system property to be set to true to enable +# creation of direct buffers using Unsafe. Without it, this falls back to ByteBuffer.allocateDirect which has +# inferior performance and risks exceeding MaxDirectMemory +-Dio.netty.tryReflectionSetAccessible=true + +### Enable vector incubator feature (simd support) + +--add-modules jdk.incubator.vector + +# The newline in the end of file is intentional diff --git a/doc/modules/cassandra/pages/new/java11.adoc b/doc/modules/cassandra/pages/new/java11.adoc index a61a57faf9a3..685e4e2f9161 100644 --- a/doc/modules/cassandra/pages/new/java11.adoc +++ b/doc/modules/cassandra/pages/new/java11.adoc @@ -9,51 +9,34 @@ After Java 8 the next LTS version is Java 11. Java 9, 10, 12 and 13 are all non-LTS versions. One of the objectives of the Apache Cassandra 4.0 version is to support -the recent LTS Java versions 8 and 11 +the LTS Java version 11 (https://issues.apache.org/jira/browse/CASSANDRA-9608[CASSANDRA-9608]). -Java 8 and Java 11 may be used to build and run Apache Cassandra 4.0. Effective Cassandra +Java 11 may be used to build and run Apache Cassandra 4.0. Effective Cassandra 4.0.2 there is full Java 11 support, it is not experimental anymore. == Support Matrix -The support matrix for the Java versions for compiling and running -Apache Cassandra 4.0 is detailed in Table 1. The build version is along -the vertical axis and the run version is along the horizontal axis. +Apache 4.0 source code built with Java 11 cannot be run with +Java 8. We support it being run only on Java 11 at the moment. -Table 1 : Support Matrix for Java +All binary releases are built with Java 11. -[width="68%",cols="34%,30%,36%",] -|=== -| |Java 8 (Run) |Java 11 (Run) -|Java 8 (Build) |Supported |Supported -|Java 11(Build) |Not Supported |Supported -|=== - -Essentially Apache 4.0 source code built with Java 11 cannot be run with -Java 8. Next, we shall discuss using each of Java 8 and 11 to build and +Next, we shall discuss using Java 11 to build and run Apache Cassandra 4.0. -== Using Java 8 to Build +== Using Java 11 to Build -To start with, install Java 8. As an example, for installing Java 8 on +To start with, install Java 11. As an example, for installing Java 11 on RedHat Linux the command is as follows: .... -$ sudo yum install java-1.8.0-openjdk-devel -.... - -Set `JAVA_HOME` and `JRE_HOME` environment variables in the shell bash -script. First, open the bash script: - -.... -$ sudo vi ~/.bashrc +$ sudo yum install java-11-openjdk .... -Set the environment variables including the `PATH`. +Set the environment variables `JAVA_HOME` and `PATH`. .... -$ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk -$ export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk/jre +$ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk $ export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin .... @@ -68,7 +51,7 @@ If Cassandra is already running stop Cassandra with the following command. .... -[ec2-user@ip-172-30-3-146 bin]$ ./nodetool stopdaemon +$ ./nodetool stopdaemon .... Build the source code from the `cassandra` directory, which has the @@ -80,7 +63,7 @@ $ cd ~/cassandra $ ant .... -Apache Cassandra 4.0 gets built with Java 8. Set the environment +Apache Cassandra 4.0 gets built with Java 11. Set the environment variable for `CASSANDRA_HOME` in the bash script. Also add the `CASSANDRA_HOME/bin` to the `PATH` variable. @@ -89,7 +72,7 @@ $ export CASSANDRA_HOME=~/cassandra $ export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$CASSANDRA_HOME/bin .... -To run Apache Cassandra 4.0 with either of Java 8 or Java 11 run the +To run Apache Cassandra 4.0 with Java 11 run the Cassandra application in the `CASSANDRA_HOME/bin` directory, which is in the `PATH` env variable. @@ -133,118 +116,18 @@ INFO [main] 2019-07-31 21:18:20,921 StorageService.java:2508 - Node 127.0.0.1:7 jump to NORMAL .... -== Using Java 11 to Build - -If Java 11 is used to build Apache Cassandra 4.0, first Java 11 must be -installed and the environment variables set. As an example, to download -and install Java 11 on RedHat Linux run the following command. - -.... -$ yum install java-11-openjdk-devel -.... - -Set the environment variables in the bash script for Java 11. The first -command is to open the bash script. - -.... -$ sudo vi ~/.bashrc -$ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk -$ export JRE_HOME=/usr/lib/jvm/java-11-openjdk/jre -$ export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin -.... - -To build source code with Java 11 one of the following two options must -be used. - -____ -[arabic] -. {blank} -+ -Include Apache Ant command-line option `-Duse.jdk=11` as follows::: -.... -$ ant -Duse.jdk=11 -.... -. {blank} -+ -Set environment variable `CASSANDRA_USE_JDK11` to `true`::: -.... -$ export CASSANDRA_USE_JDK11=true -.... -____ - -As an example, set the environment variable `CASSANDRA_USE_JDK11` to -`true`. - -.... -[ec2-user@ip-172-30-3-146 cassandra]$ export CASSANDRA_USE_JDK11=true -[ec2-user@ip-172-30-3-146 cassandra]$ ant -Buildfile: /home/ec2-user/cassandra/build.xml -.... - -Or, set the command-line option. - -.... -[ec2-user@ip-172-30-3-146 cassandra]$ ant -Duse.jdk11=true -.... - -The build output should include the following. - -.... -_build_java: - [echo] Compiling for Java 11 -... -... -build: - -_main-jar: - [copy] Copying 1 file to /home/ec2-user/cassandra/build/classes/main/META-INF - [jar] Building jar: /home/ec2-user/cassandra/build/apache-cassandra-4.0-SNAPSHOT.jar -... -... -_build-test: - [javac] Compiling 739 source files to /home/ec2-user/cassandra/build/test/classes - [copy] Copying 25 files to /home/ec2-user/cassandra/build/test/classes -... -... -jar: - [mkdir] Created dir: /home/ec2-user/cassandra/build/classes/stress/META-INF - [mkdir] Created dir: /home/ec2-user/cassandra/build/tools/lib - [jar] Building jar: /home/ec2-user/cassandra/build/tools/lib/stress.jar - [mkdir] Created dir: /home/ec2-user/cassandra/build/classes/fqltool/META-INF - [jar] Building jar: /home/ec2-user/cassandra/build/tools/lib/fqltool.jar - -BUILD SUCCESSFUL -Total time: 1 minute 3 seconds -[ec2-user@ip-172-30-3-146 cassandra]$ -.... - == Common Issues -One of the two options mentioned must be used to compile with JDK 11 or -the build fails and the following error message is output. - -.... -[ec2-user@ip-172-30-3-146 cassandra]$ ant -Buildfile: /home/ec2-user/cassandra/build.xml -validate-build-conf: - -BUILD FAILED -/home/ec2-user/cassandra/build.xml:293: -Duse.jdk11=true or $CASSANDRA_USE_JDK11=true must -be set when building from java 11 -Total time: 1 second -[ec2-user@ip-172-30-3-146 cassandra]$ -.... - The Java 11 built Apache Cassandra 4.0 source code may be run with Java 11 only. If a Java 11 built code is run with Java 8 the following error message gets output. .... -[root@localhost ~]# ssh -i cassandra.pem ec2-user@ec2-3-85-85-75.compute-1.amazonaws.com +# ssh -i cassandra.pem ec2-user@ec2-3-85-85-75.compute-1.amazonaws.com Last login: Wed Jul 31 20:47:26 2019 from 75.155.255.51 -[ec2-user@ip-172-30-3-146 ~]$ echo $JAVA_HOME +$ echo $JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk -[ec2-user@ip-172-30-3-146 ~]$ cassandra +$ cassandra ... ... Error: A JNI error has occurred, please check your installation and try again @@ -258,33 +141,3 @@ class file versions up to 52.0 ... .... -The `CASSANDRA_USE_JDK11` variable or the command-line option -`-Duse.jdk11` cannot be used to build with Java 8. To demonstrate set -`JAVA_HOME` to version 8. - -.... -[root@localhost ~]# ssh -i cassandra.pem ec2-user@ec2-3-85-85-75.compute-1.amazonaws.com -Last login: Wed Jul 31 21:41:50 2019 from 75.155.255.51 -[ec2-user@ip-172-30-3-146 ~]$ echo $JAVA_HOME -/usr/lib/jvm/java-1.8.0-openjdk -.... - -Set the `CASSANDRA_USE_JDK11=true` or command-line option -`-Duse.jdk11=true`. Subsequently, run Apache Ant to start the build. The -build fails with error message listed. - -.... -[ec2-user@ip-172-30-3-146 ~]$ cd -cassandra -[ec2-user@ip-172-30-3-146 cassandra]$ export CASSANDRA_USE_JDK11=true -[ec2-user@ip-172-30-3-146 cassandra]$ ant -Buildfile: /home/ec2-user/cassandra/build.xml - -validate-build-conf: - -BUILD FAILED -/home/ec2-user/cassandra/build.xml:285: -Duse.jdk11=true or $CASSANDRA_USE_JDK11=true cannot -be set when building from java 8 - -Total time: 0 seconds -.... diff --git a/pylib/cassandra-cqlsh-tests.sh b/pylib/cassandra-cqlsh-tests.sh index e8c051d48fb2..ccc3aff42774 100755 --- a/pylib/cassandra-cqlsh-tests.sh +++ b/pylib/cassandra-cqlsh-tests.sh @@ -50,9 +50,6 @@ fi if [[ -z "${java_version}" ]]; then java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//g' | awk -F. '{print $1}') fi -if [[ ${java_version} -ge 11 ]]; then - export CASSANDRA_USE_JDK11=true -fi if [[ -z "${python_version}" ]]; then python_version="3.8" diff --git a/test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java b/test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java new file mode 100644 index 000000000000..59aba5e46420 --- /dev/null +++ b/test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.anttasks; + +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; + +public class JdkProperties extends Task +{ + + public void execute() + { + Project project = getProject(); + project.setNewProperty("java.version." + project.getProperty("ant.java.version"), "true"); + project.setNewProperty("use-jdk" + project.getProperty("ant.java.version"), "true"); + } +} diff --git a/test/unit/org/apache/cassandra/index/sai/metrics/QueryMetricsTest.java b/test/unit/org/apache/cassandra/index/sai/metrics/QueryMetricsTest.java index a328b84b21e6..56e907dfb9c6 100644 --- a/test/unit/org/apache/cassandra/index/sai/metrics/QueryMetricsTest.java +++ b/test/unit/org/apache/cassandra/index/sai/metrics/QueryMetricsTest.java @@ -261,7 +261,7 @@ public void testKDTreePostingsQueryMetricsWithSingleIndex() // V2 index is very selective, so it should lead the union merge process, causing V1 index to be not used at all. execute("SELECT id1 FROM " + keyspace + "." + table + " WHERE v1 >= 0 AND v1 <= 1000 AND v2 = '5' ALLOW FILTERING"); - waitForVerifyHistogram(objectNameNoIndex("KDTreePostingsSkips", keyspace, table, PER_QUERY_METRIC_TYPE), 1); + waitForVerifyHistogram(objectNameNoIndex("KDTreePostingsSkips", keyspace, table, PER_QUERY_METRIC_TYPE), 2); } @Test diff --git a/tools/bin/cassandra.in.sh b/tools/bin/cassandra.in.sh index 27c81cb73ca6..f17730d56a41 100644 --- a/tools/bin/cassandra.in.sh +++ b/tools/bin/cassandra.in.sh @@ -80,22 +80,17 @@ fi java_ver_output=`"${JAVA:-java}" -version 2>&1` jvmver=`echo "$java_ver_output" | grep '[openjdk|java] version' | awk -F'"' 'NR==1 {print $2}' | cut -d\- -f1` JVM_VERSION=${jvmver%_*} +short=$(echo "${jvmver}" | cut -c1-2) -JAVA_VERSION=11 -if [ "$JVM_VERSION" = "1.8.0" ] ; then - JVM_PATCH_VERSION=${jvmver#*_} - if [ "$JVM_VERSION" \< "1.8" ] || [ "$JVM_VERSION" \> "1.8.2" ] ; then - echo "Cassandra 4.0 requires either Java 8 (update 151 or newer) or Java 11 (or newer). Java $JVM_VERSION is not supported." - exit 1; - fi - if [ "$JVM_PATCH_VERSION" -lt 151 ] ; then - echo "Cassandra 4.0 requires either Java 8 (update 151 or newer) or Java 11 (or newer). Java 8 update $JVM_PATCH_VERSION is not supported." - exit 1; - fi - JAVA_VERSION=8 -elif [ "$JVM_VERSION" \< "11" ] ; then - echo "Cassandra 4.0 requires either Java 8 (update 151 or newer) or Java 11 (or newer)." +JAVA_VERSION=22 + +if [ "$JVM_VERSION" \< "11" ] ; then + echo "Cassandra 4.0 requires either Java 11 or newer." exit 1; +elif [ "$short" = "11" ] ; then + JAVA_VERSION=11 +elif [ "$JVM_VERSION" \< "22" ] ; then + echo "Cassandra requires Java 11 or Java 22(or newer)." fi jvm=`echo "$java_ver_output" | grep -A 1 '[openjdk|java] version' | awk 'NR==2 {print $1}'` @@ -119,7 +114,11 @@ esac # Read user-defined JVM options from jvm-server.options file JVM_OPTS_FILE=$CASSANDRA_CONF/jvm${jvmoptions_variant:--clients}.options -if [ $JAVA_VERSION -ge 11 ] ; then +if [ $JAVA_VERSION -ge 22 ] ; then + JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm22${jvmoptions_variant:--clients}.options +elif [ $JAVA_VERSION -ge 17 ] ; then + JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm17${jvmoptions_variant:--clients}.options +elif [ $JAVA_VERSION -ge 11 ] ; then JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm11${jvmoptions_variant:--clients}.options else JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm8${jvmoptions_variant:--clients}.options