At the end of July, support for Java 11 was merged into the Apache Cassandra trunk, which will be shipped in the next major release, Cassandra 4.0. Prior to this, Cassandra 3.0 only ran using Java 8, since there were breaking changes in Java that prevented it from run on later versions. Cassandra now supports both Java 8 and 11.
To run Cassandra on Java 11, you’ll need to first download an early access build of jdk java 11, since there’s still no official released. I downloaded a build for my Mac and untar’ed the archive.
Next, you’ll need to set the environment variables. On my mac I’ve set the following variables:
$ export JAVA_HOME="/Users/jhaddad/Downloads/jdk-11.jdk/Contents/Home"
$ export JAVA8_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home"
You can get Cassandra by cloning the git repo and building using ant
:
$ git clone https://github.com/apache/cassandra.git
$ cd cassandra
$ ant
You should see the build script finish with something like the following:
write-poms:
[script] Warning: Nashorn engine is planned to be removed from a future JDK release
init:
maven-ant-tasks-localrepo:
maven-ant-tasks-download:
maven-ant-tasks-init:
maven-declare-dependencies:
_write-poms:
build-test:
jar:
[jar] Building jar: /Users/jhaddad/dev/cassandra/build/tools/lib/stress.jar
BUILD SUCCESSFUL
Total time: 7 seconds
You can now start Cassandra with the following:
$ bin/cassandra -f
One feature that could be a big deal over time is the new garbage collection algorithm, ZGC. The goal of ZGC is to work on huge heaps while maintaining low latency, 10ms or less. If it delivers on the promise, we could avoid an entire optimization process that many teams struggle with. It can be enabled with these JVM flags.
-XX:+UnlockExperimentalVMOptions
-XX:+UseZGC
To use ZGC in Cassandra 4.0, you can add the JVM flags to the cassandra-env.sh file located in the conf directory of the repository as shown below. Note that flags are add above the JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS"
line at the end of the file.
JVM_OPTS="$JVM_OPTS -XX:+UnlockExperimentalVMOptions"
JVM_OPTS="$JVM_OPTS -XX:+UseZGC"
JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS"
The Cassandra team intends to freeze the trunk
branch in September, committing to bug fixes and stability improvements before releasing 4.0. We’d love feedback on the release during this period - especially in regards to performance with Java 11. We appreciate any help testing real world workloads (in a staging environment!). Bugs can be reported to the Cassandra JIRA. We aim to make the 4.0 release stable on day one. We encourage everyone to get involved early to ensure the high quality of this important release!