From 98bf7df17bb77ddd7ac8aa321be6270f5eec8a58 Mon Sep 17 00:00:00 2001 From: Mick Semb Wever Date: Sat, 21 Jan 2023 12:46:56 +0100 Subject: [PATCH 01/17] Removes the use of CASSANDRA_USE_JDK11 and introduces the build.xml properties `java.default` and `java.supported`. ant generate-idea-files now support JDK 8, JDK 11 and JDK 22. To add support of another JDK the java-jvmargs property must be set for the JDK in question (see how it's done in build.xml for Java 11 and 22) Other minor, but notable changes are: - test jvmargs are now added to idea run configurations - .idea dir and project iml file are first removed and then recreated during `ant generate-idea-files` Based on what was done in CASSANDRA-18467, CASSANDRA-18179, CASSANDRA-18258 for 17 plus additional stuff for 21 Co-authored-by: Ekaterina Dimitrova Co-authored-by: Mick Semb Wever Co-authored-by: Jakub Zytka --- bin/cassandra.in.sh | 4 +- build.xml | 242 ++++++++++-------- conf/jvm22-clients.options | 29 +++ conf/jvm22-server.options | 129 ++++++++++ doc/modules/cassandra/pages/new/java11.adoc | 118 ++------- pylib/cassandra-cqlsh-tests.sh | 1 + .../cassandra/anttasks/JdkProperties.java | 33 +++ tools/bin/cassandra.in.sh | 6 +- 8 files changed, 358 insertions(+), 204 deletions(-) create mode 100644 conf/jvm22-clients.options create mode 100644 conf/jvm22-server.options create mode 100644 test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java 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..5f8763b42f76 100644 --- a/build.xml +++ b/build.xml @@ -38,6 +38,16 @@ + + + + + @@ -196,16 +206,11 @@ - - - - - - - - - - + + + + + -Djdk.attach.allowAttachSelf=true @@ -248,11 +253,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.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.naming.dns/com.sun.jndi.dns=java.naming + --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED + --add-exports java.base/jdk.internal.util.jar=ALL-UNNAMED + + --add-opens java.base/jdk.internal.module=ALL-UNNAMED + --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED + --add-opens java.base/jdk.internal.loader=ALL-UNNAMED + --add-opens java.base/jdk.internal.ref=ALL-UNNAMED + --add-opens java.base/jdk.internal.math=ALL-UNNAMED + --add-opens java.base/java.math=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.lang.module=ALL-UNNAMED + --add-opens java.base/java.net=ALL-UNNAMED + --add-opens java.base/java.io=ALL-UNNAMED + --add-opens java.base/sun.nio.ch=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.lang=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + --add-opens java.base/java.lang.reflect=ALL-UNNAMED + --add-opens java.base/java.lang.ref=ALL-UNNAMED + --add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED + --add-opens java.base/jdk.internal.vm=ALL-UNNAMED + --add-opens java.base/java.util.concurrent.locks=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-modules jdk.incubator.vector + + + + + + + @@ -291,17 +375,6 @@ - - - - - - - - - - - @@ -344,57 +417,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -406,6 +432,13 @@ + + + + + + + @@ -950,7 +983,7 @@ - + @@ -962,11 +995,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 +1031,7 @@ @@ -1015,7 +1048,7 @@ @@ -1056,7 +1089,7 @@ @@ -1073,7 +1106,7 @@ @@ -1366,8 +1399,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 +1524,19 @@ - + - + - + @@ -2191,13 +2223,13 @@ - - - - + + + + @@ -2213,6 +2245,8 @@ + + @@ -2230,7 +2264,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 +2369,9 @@ failonerror="true" maxmemory="512m"> - + - + diff --git a/conf/jvm22-clients.options b/conf/jvm22-clients.options new file mode 100644 index 000000000000..a076b8051d7c --- /dev/null +++ b/conf/jvm22-clients.options @@ -0,0 +1,29 @@ +########################################################################### +# 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-opens java.base/java.lang.module=ALL-UNNAMED +--add-opens java.base/jdk.internal.loader=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.math=ALL-UNNAMED +--add-opens java.base/jdk.internal.module=ALL-UNNAMED +--add-opens java.base/jdk.internal.util.jar=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..c76ba9905481 --- /dev/null +++ b/conf/jvm22-server.options @@ -0,0 +1,129 @@ +########################################################################### +# jvm22-server.options # +# # +# See jvm-server.options. This file is specific for Java 22 and newer. # +########################################################################### + +################# +# GC SETTINGS # +################# + + + +### CMS Settings +#-XX:+UseConcMarkSweepGC +#-XX:+CMSParallelRemarkEnabled +#-XX:SurvivorRatio=8 +#-XX:MaxTenuringThreshold=1 +#-XX:CMSInitiatingOccupancyFraction=75 +#-XX:+UseCMSInitiatingOccupancyOnly +#-XX:CMSWaitDuration=10000 +#-XX:+CMSParallelInitialMarkEnabled +#-XX:+CMSEdenChunksRecordAlways +## some JVMs will fill up their heap when accessed via JMX, see CASSANDRA-6541 +#-XX:+CMSClassUnloadingEnabled + + + +### 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 +--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 java.sql/java.sql=ALL-UNNAMED --> not seen in +# Below exist in the other script +--add-exports jdk.naming.dns/com.sun.jndi.dns=java.naming +--add-exports jdk.unsupported/sun.misc=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + +--add-opens java.base/jdk.internal.loader=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.math=ALL-UNNAMED +# --add-opens java.base/jdk.internal.module=ALL-UNNAMED +--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED +--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED +# Added in +--add-opens java.base/java.lang.module=ALL-UNNAMED +--add-opens jdk.management.jfr/jdk.management.jfr=ALL-UNNAMED +--add-opens jdk.naming.dns/com.sun.jndi.dns=ALL-UNNAMED +--add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED +--add-opens java.base/sun.nio.ch=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.lang=ALL-UNNAMED +--add-opens java.base/java.lang.reflect=ALL-UNNAMED +--add-opens java.base/java.io=ALL-UNNAMED +--add-opens java.base/java.util=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 + +### Compatibility Options +--add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED +-Djava.security.manager=allow + +# 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..ded5c2eab18c 100644 --- a/doc/modules/cassandra/pages/new/java11.adoc +++ b/doc/modules/cassandra/pages/new/java11.adoc @@ -26,11 +26,15 @@ Table 1 : Support Matrix for Java |=== | |Java 8 (Run) |Java 11 (Run) |Java 8 (Build) |Supported |Supported -|Java 11(Build) |Not Supported |Supported +|Java 11(Build) |Not Supported |Experimental |=== -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 +Apache 4.0 source code built with Java 11 cannot be run with +Java 8. + +All binary releases are built with Java 8. + +Next, we shall discuss using each of Java 8 and 11 to build and run Apache Cassandra 4.0. == Using Java 8 to Build @@ -42,18 +46,10 @@ 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 -.... - -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 PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin .... @@ -68,7 +64,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 @@ -143,53 +139,19 @@ 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. +Set the environment variables `JAVA_HOME` and `PATH`. .... -$ 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. +The build output should now include the following. .... +[echo] Non default JDK version used: 11 +... +... _build_java: [echo] Compiling for Java 11 ... @@ -215,36 +177,20 @@ 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 +204,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..e581b619dbac 100755 --- a/pylib/cassandra-cqlsh-tests.sh +++ b/pylib/cassandra-cqlsh-tests.sh @@ -43,6 +43,7 @@ export CCM_CONFIG_DIR="${TMPDIR}/.ccm" export NUM_TOKENS="16" export CASSANDRA_DIR=${WORKSPACE} +# Kate, there was some conflict after CNDB-10190, check this later, for now I focused on the unit tests so ignore it... if [[ -z "${version}" ]]; then version=$(grep 'property\s*name=\"base.version\"' ${CASSANDRA_DIR}/build.xml |sed -ne 's/.*value=\"\([^"]*\)\".*/\1/p') fi 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..2e5d202a20d9 --- /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").replace("1.", ""), "true"); + project.setNewProperty("use-jdk" + project.getProperty("ant.java.version").replace("1.", ""), "true"); + } +} diff --git a/tools/bin/cassandra.in.sh b/tools/bin/cassandra.in.sh index 27c81cb73ca6..4370fc144b02 100644 --- a/tools/bin/cassandra.in.sh +++ b/tools/bin/cassandra.in.sh @@ -119,7 +119,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 From e9276babe1b46817cf2e0cbfe4c34e331ff78bc7 Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Wed, 30 Oct 2024 17:57:01 -0400 Subject: [PATCH 02/17] Fix add-opens and add-exports --- build.xml | 2 +- conf/jvm22-clients.options | 2 +- conf/jvm22-server.options | 33 ++++++++------------------------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/build.xml b/build.xml index 5f8763b42f76..b05a2a4a5b5e 100644 --- a/build.xml +++ b/build.xml @@ -293,7 +293,6 @@ --add-exports jdk.naming.dns/com.sun.jndi.dns=java.naming --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED - --add-exports java.base/jdk.internal.util.jar=ALL-UNNAMED --add-opens java.base/jdk.internal.module=ALL-UNNAMED --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED @@ -324,6 +323,7 @@ --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 diff --git a/conf/jvm22-clients.options b/conf/jvm22-clients.options index a076b8051d7c..d3d0e1725ab8 100644 --- a/conf/jvm22-clients.options +++ b/conf/jvm22-clients.options @@ -23,7 +23,7 @@ --add-opens java.base/jdk.internal.reflect=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.util.jar=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED +--add-opens=java.base/java.lang.reflect=ALL-UNNAMED # The newline in the end of file is intentional diff --git a/conf/jvm22-server.options b/conf/jvm22-server.options index c76ba9905481..518b559d27b7 100644 --- a/conf/jvm22-server.options +++ b/conf/jvm22-server.options @@ -8,23 +8,6 @@ # GC SETTINGS # ################# - - -### CMS Settings -#-XX:+UseConcMarkSweepGC -#-XX:+CMSParallelRemarkEnabled -#-XX:SurvivorRatio=8 -#-XX:MaxTenuringThreshold=1 -#-XX:CMSInitiatingOccupancyFraction=75 -#-XX:+UseCMSInitiatingOccupancyOnly -#-XX:CMSWaitDuration=10000 -#-XX:+CMSParallelInitialMarkEnabled -#-XX:+CMSEdenChunksRecordAlways -## some JVMs will fill up their heap when accessed via JMX, see CASSANDRA-6541 -#-XX:+CMSClassUnloadingEnabled - - - ### G1 Settings ## Use the Hotspot garbage-first collector. -XX:+UseG1GC @@ -64,8 +47,6 @@ --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 --> not seen in -# Below exist in the other script --add-exports jdk.naming.dns/com.sun.jndi.dns=java.naming --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED @@ -74,24 +55,26 @@ --add-opens java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/jdk.internal.reflect=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.util.jar=ALL-UNNAMED +--add-opens java.base/jdk.internal.module=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED -# Added in --add-opens java.base/java.lang.module=ALL-UNNAMED --add-opens jdk.management.jfr/jdk.management.jfr=ALL-UNNAMED --add-opens jdk.naming.dns/com.sun.jndi.dns=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED ---add-opens java.base/sun.nio.ch=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.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED +--add-opens java.base/jdk.internal.vm=ALL-UNNAMED +--add-opens java.base/java.util.concurrent.locks=ALL-UNNAMED +# required for org.apache.cassandra.Util.getSupportedMTimeGranularity +--add-opens java.base/java.nio.file.attribute=ALL-UNNAMED + +--add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED ### GC logging options -- uncomment to enable @@ -123,7 +106,7 @@ --add-modules jdk.incubator.vector ### Compatibility Options ---add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.lang=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.io=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED -Djava.security.manager=allow # The newline in the end of file is intentional From dcc4035823817f9f0312555e86c5ef8d408e90d7 Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Wed, 30 Oct 2024 18:44:02 -0400 Subject: [PATCH 03/17] CNDB-11508: CQLSHLIB tests update --- conf/jvm22-server.options | 2 +- pylib/cassandra-cqlsh-tests.sh | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/conf/jvm22-server.options b/conf/jvm22-server.options index 518b559d27b7..79b83707f0a6 100644 --- a/conf/jvm22-server.options +++ b/conf/jvm22-server.options @@ -81,7 +81,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/pylib/cassandra-cqlsh-tests.sh b/pylib/cassandra-cqlsh-tests.sh index e581b619dbac..ccc3aff42774 100755 --- a/pylib/cassandra-cqlsh-tests.sh +++ b/pylib/cassandra-cqlsh-tests.sh @@ -43,7 +43,6 @@ export CCM_CONFIG_DIR="${TMPDIR}/.ccm" export NUM_TOKENS="16" export CASSANDRA_DIR=${WORKSPACE} -# Kate, there was some conflict after CNDB-10190, check this later, for now I focused on the unit tests so ignore it... if [[ -z "${version}" ]]; then version=$(grep 'property\s*name=\"base.version\"' ${CASSANDRA_DIR}/build.xml |sed -ne 's/.*value=\"\([^"]*\)\".*/\1/p') fi @@ -51,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" From b704e1fbaa4f5155f542a5c4d1a5b14eaecb4a70 Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Thu, 31 Oct 2024 15:22:14 -0400 Subject: [PATCH 04/17] Fix EmptyValuesTest --- conf/jvm22-clients.options | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/jvm22-clients.options b/conf/jvm22-clients.options index d3d0e1725ab8..b8f40b7b826b 100644 --- a/conf/jvm22-clients.options +++ b/conf/jvm22-clients.options @@ -25,5 +25,7 @@ --add-opens java.base/jdk.internal.module=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED +--add-opens java.base/java.io=ALL-UNNAMED +--add-opens java.base/sun.nio.ch=ALL-UNNAMED # The newline in the end of file is intentional From 8dcefd2e6d8d536c512bf91527dafffa1cc2005a Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Thu, 31 Oct 2024 15:31:57 -0400 Subject: [PATCH 05/17] Fix sjk --- conf/jvm22-clients.options | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/jvm22-clients.options b/conf/jvm22-clients.options index b8f40b7b826b..29a60115447c 100644 --- a/conf/jvm22-clients.options +++ b/conf/jvm22-clients.options @@ -16,6 +16,7 @@ --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.lang.module=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED From c17eb8ea15289e15c23f67baa74b9d9f12fa4b90 Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Mon, 22 Jul 2024 17:11:38 -0400 Subject: [PATCH 06/17] Fix tools/bin/cassandra.in.sh; fix some JDK internals openings for audit logger and vectorizedMismatch --- build.xml | 1 + conf/jvm22-server.options | 1 + tools/bin/cassandra.in.sh | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/build.xml b/build.xml index b05a2a4a5b5e..4f98726dfe48 100644 --- a/build.xml +++ b/build.xml @@ -293,6 +293,7 @@ --add-exports jdk.naming.dns/com.sun.jndi.dns=java.naming --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED + --add-exports java.base/jdk.internal.util.jar=ALL-UNNAMED --add-opens java.base/jdk.internal.module=ALL-UNNAMED --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED diff --git a/conf/jvm22-server.options b/conf/jvm22-server.options index 79b83707f0a6..1e5260882fe1 100644 --- a/conf/jvm22-server.options +++ b/conf/jvm22-server.options @@ -50,6 +50,7 @@ --add-exports jdk.naming.dns/com.sun.jndi.dns=java.naming --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED +--add-exports java.base/jdk.internal.util.jar=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/jdk.internal.ref=ALL-UNNAMED diff --git a/tools/bin/cassandra.in.sh b/tools/bin/cassandra.in.sh index 4370fc144b02..31e9728b94c6 100644 --- a/tools/bin/cassandra.in.sh +++ b/tools/bin/cassandra.in.sh @@ -76,12 +76,16 @@ if [ -z $JAVA ] ; then exit 1; fi +java_versions_supported=11,17,22 + # Determine the sort of JVM we'll be running on. 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=22 -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 @@ -96,6 +100,10 @@ if [ "$JVM_VERSION" = "1.8.0" ] ; then elif [ "$JVM_VERSION" \< "11" ] ; then echo "Cassandra 4.0 requires either Java 8 (update 151 or newer) or 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}'` From b021a7f58080f52cb53ccee4cacf81099eecbab2 Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Sat, 2 Nov 2024 15:37:42 -0400 Subject: [PATCH 07/17] Upgrade Mockito to fix UnifiedCompactionStrategyTest --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index 4f98726dfe48..95a1a66969d8 100644 --- a/build.xml +++ b/build.xml @@ -614,7 +614,7 @@ - + From 9d8abc24894d98fb1458b21075211183b1d0894b Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Tue, 5 Nov 2024 16:33:20 -0500 Subject: [PATCH 08/17] Get rid of JDK8 in scripts, not supported anywhere anymore --- build.xml | 2 +- tools/bin/cassandra.in.sh | 17 ++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/build.xml b/build.xml index 95a1a66969d8..6537004faa6b 100644 --- a/build.xml +++ b/build.xml @@ -46,7 +46,7 @@ --> - + diff --git a/tools/bin/cassandra.in.sh b/tools/bin/cassandra.in.sh index 31e9728b94c6..f17730d56a41 100644 --- a/tools/bin/cassandra.in.sh +++ b/tools/bin/cassandra.in.sh @@ -76,8 +76,6 @@ if [ -z $JAVA ] ; then exit 1; fi -java_versions_supported=11,17,22 - # Determine the sort of JVM we'll be running on. 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` @@ -86,19 +84,8 @@ short=$(echo "${jvmver}" | cut -c1-2) JAVA_VERSION=22 -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)." +if [ "$JVM_VERSION" \< "11" ] ; then + echo "Cassandra 4.0 requires either Java 11 or newer." exit 1; elif [ "$short" = "11" ] ; then JAVA_VERSION=11 From 1082a2065cf674c48ce2c6144f9f7a22ce13ba1e Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Thu, 7 Nov 2024 16:06:35 -0500 Subject: [PATCH 09/17] Remove useless comment --- build.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/build.xml b/build.xml index 6537004faa6b..81aa9c22a94a 100644 --- a/build.xml +++ b/build.xml @@ -42,7 +42,6 @@ All releases are built with the default JDK. Builds with non-default JDKs are considered experimental and for development and testing purposes. When building, javac's source and target flags are set to the jdk used, so lower JDKs are not supported at runtime. - The use of both CASSANDRA_USE_JDK11 and use-jdk11 is deprecated. --> From 08ebb0d6a57e421f8bbe08338e4d2b903259bf39 Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Thu, 7 Nov 2024 16:07:03 -0500 Subject: [PATCH 10/17] JdkProperties does not need to account for JDK8 anymore --- .../anttasks/org/apache/cassandra/anttasks/JdkProperties.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java b/test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java index 2e5d202a20d9..59aba5e46420 100644 --- a/test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java +++ b/test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java @@ -27,7 +27,7 @@ public class JdkProperties extends Task public void execute() { Project project = getProject(); - project.setNewProperty("java.version." + project.getProperty("ant.java.version").replace("1.", ""), "true"); - project.setNewProperty("use-jdk" + project.getProperty("ant.java.version").replace("1.", ""), "true"); + project.setNewProperty("java.version." + project.getProperty("ant.java.version"), "true"); + project.setNewProperty("use-jdk" + project.getProperty("ant.java.version"), "true"); } } From 8e686273e58bab23755253a520a8ed0a2ef45afa Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Thu, 7 Nov 2024 16:36:38 -0500 Subject: [PATCH 11/17] Sort alphabetically add-exports/add-opens as per review request --- build.xml | 37 ++++++++++++++++++------------------- conf/jvm22-clients.options | 10 +++++----- conf/jvm22-server.options | 37 +++++++++++++++++++++---------------- 3 files changed, 44 insertions(+), 40 deletions(-) diff --git a/build.xml b/build.xml index 81aa9c22a94a..0b0e660c59ac 100644 --- a/build.xml +++ b/build.xml @@ -285,38 +285,37 @@ --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/jdk.internal.util.jar=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.naming.dns/com.sun.jndi.dns=java.naming --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-exports java.base/jdk.internal.util.jar=ALL-UNNAMED - --add-opens java.base/jdk.internal.module=ALL-UNNAMED - --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED - --add-opens java.base/jdk.internal.loader=ALL-UNNAMED - --add-opens java.base/jdk.internal.ref=ALL-UNNAMED - --add-opens java.base/jdk.internal.math=ALL-UNNAMED - --add-opens java.base/java.math=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.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.io=ALL-UNNAMED - --add-opens java.base/sun.nio.ch=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.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED - --add-opens java.base/java.lang.reflect=ALL-UNNAMED - --add-opens java.base/java.lang.ref=ALL-UNNAMED - --add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED - --add-opens java.base/jdk.internal.vm=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 diff --git a/conf/jvm22-clients.options b/conf/jvm22-clients.options index 29a60115447c..42ee72e33a67 100644 --- a/conf/jvm22-clients.options +++ b/conf/jvm22-clients.options @@ -18,15 +18,15 @@ --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.ref=ALL-UNNAMED ---add-opens java.base/jdk.internal.reflect=ALL-UNNAMED --add-opens java.base/jdk.internal.math=ALL-UNNAMED --add-opens java.base/jdk.internal.module=ALL-UNNAMED ---add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED ---add-opens=java.base/java.lang.reflect=ALL-UNNAMED ---add-opens java.base/java.io=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 index 1e5260882fe1..c28e659a6edd 100644 --- a/conf/jvm22-server.options +++ b/conf/jvm22-server.options @@ -43,34 +43,34 @@ --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/jdk.internal.util.jar=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-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED ---add-exports java.base/jdk.internal.util.jar=ALL-UNNAMED ---add-opens java.base/jdk.internal.loader=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.math=ALL-UNNAMED ---add-opens java.base/jdk.internal.module=ALL-UNNAMED ---add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED +--add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang.module=ALL-UNNAMED ---add-opens jdk.management.jfr/jdk.management.jfr=ALL-UNNAMED ---add-opens jdk.naming.dns/com.sun.jndi.dns=ALL-UNNAMED ---add-opens jdk.compiler/com.sun.tools.javac=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.lang=ALL-UNNAMED ---add-opens java.base/java.lang.reflect=ALL-UNNAMED ---add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED ---add-opens java.base/jdk.internal.vm=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 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 @@ -107,7 +107,12 @@ --add-modules jdk.incubator.vector ### Compatibility Options ---add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED +--add-opens java.base/java.io=ALL-UNNAMED +--add-opens java.base/java.lang=ALL-UNNAMED +--add-opens java.base/java.nio=ALL-UNNAMED +--add-opens java.base/java.util=ALL-UNNAMED +--add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED +--add-opens java.base/sun.nio.ch=ALL-UNNAMED -Djava.security.manager=allow # The newline in the end of file is intentional From 7e25ccabf86122a3f443b25e949c01844062e22b Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Fri, 8 Nov 2024 11:51:48 -0500 Subject: [PATCH 12/17] Update the Java 11 doc as per review agreeement --- doc/modules/cassandra/pages/new/java11.adoc | 85 +++------------------ 1 file changed, 11 insertions(+), 74 deletions(-) diff --git a/doc/modules/cassandra/pages/new/java11.adoc b/doc/modules/cassandra/pages/new/java11.adoc index ded5c2eab18c..685e4e2f9161 100644 --- a/doc/modules/cassandra/pages/new/java11.adoc +++ b/doc/modules/cassandra/pages/new/java11.adoc @@ -9,47 +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. - -Table 1 : Support Matrix for Java - -[width="68%",cols="34%,30%,36%",] -|=== -| |Java 8 (Run) |Java 11 (Run) -|Java 8 (Build) |Supported |Supported -|Java 11(Build) |Not Supported |Experimental -|=== - Apache 4.0 source code built with Java 11 cannot be run with -Java 8. +Java 8. We support it being run only on Java 11 at the moment. -All binary releases are built with Java 8. +All binary releases are built with Java 11. -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 +$ sudo yum install java-11-openjdk .... Set the environment variables `JAVA_HOME` and `PATH`. .... -$ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk +$ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk $ export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin .... @@ -76,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. @@ -85,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. @@ -129,56 +116,6 @@ 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 `JAVA_HOME` and `PATH`. - -.... -$ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk -$ export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin -.... - -The build output should now include the following. - -.... -[echo] Non default JDK version used: 11 -... -... -_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 -.... - == Common Issues The Java 11 built Apache Cassandra 4.0 source code may be run with Java From c757061bba3c64c871b8c89d493aaf4ecca1d330 Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Wed, 20 Nov 2024 15:04:59 -0500 Subject: [PATCH 13/17] Address review feedback --- conf/jvm11-server.options | 2 +- conf/jvm17-server.options | 2 +- conf/jvm22-server.options | 16 ++++------------ 3 files changed, 6 insertions(+), 14 deletions(-) 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-server.options b/conf/jvm22-server.options index c28e659a6edd..19b660a5381a 100644 --- a/conf/jvm22-server.options +++ b/conf/jvm22-server.options @@ -40,6 +40,7 @@ ### 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 @@ -60,6 +61,7 @@ --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 @@ -67,6 +69,7 @@ --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 @@ -75,14 +78,12 @@ # required for org.apache.cassandra.Util.getSupportedMTimeGranularity --add-opens java.base/java.nio.file.attribute=ALL-UNNAMED ---add-opens jdk.compiler/com.sun.tools.javac=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 +# -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: # @@ -106,13 +107,4 @@ --add-modules jdk.incubator.vector -### Compatibility Options ---add-opens java.base/java.io=ALL-UNNAMED ---add-opens java.base/java.lang=ALL-UNNAMED ---add-opens java.base/java.nio=ALL-UNNAMED ---add-opens java.base/java.util=ALL-UNNAMED ---add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED ---add-opens java.base/sun.nio.ch=ALL-UNNAMED --Djava.security.manager=allow - # The newline in the end of file is intentional From 195b89e81825873e2dbb24d80671361db306af4e Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Fri, 22 Nov 2024 18:03:34 -0500 Subject: [PATCH 14/17] Remove jdk internals export which is not needed anymore with JDK22, this was already done with the main-5.0 patch, but forgotten here --- build.xml | 1 - conf/jvm22-server.options | 1 - 2 files changed, 2 deletions(-) diff --git a/build.xml b/build.xml index 0b0e660c59ac..a428afa61794 100644 --- a/build.xml +++ b/build.xml @@ -285,7 +285,6 @@ --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/jdk.internal.util.jar=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 diff --git a/conf/jvm22-server.options b/conf/jvm22-server.options index 19b660a5381a..236ca90f0968 100644 --- a/conf/jvm22-server.options +++ b/conf/jvm22-server.options @@ -44,7 +44,6 @@ --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/jdk.internal.util.jar=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 From 4fe776b184191e23294968541cecaa546452e8e6 Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Sun, 8 Dec 2024 15:50:42 -0500 Subject: [PATCH 15/17] Mockito same version as the 5.0 branch --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index a428afa61794..b9ececd5bb2c 100644 --- a/build.xml +++ b/build.xml @@ -611,7 +611,7 @@ - + From c9b253a16347b7d6f446fbe89453082c6595d81c Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Tue, 10 Dec 2024 14:59:11 -0500 Subject: [PATCH 16/17] Add export needed by bytebuddy version we currently download --- build.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.xml b/build.xml index b9ececd5bb2c..628b11c874e4 100644 --- a/build.xml +++ b/build.xml @@ -283,8 +283,9 @@ --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/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 From 687ec9ba36469b483e88acfa9969fce5d84d084d Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Thu, 12 Dec 2024 21:30:48 -0500 Subject: [PATCH 17/17] Fix testKDTreeQueryMetricsWithSingleIndex post CNDB-10629 --- .../apache/cassandra/index/sai/metrics/QueryMetricsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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