In a server with Cassandra 4 with the files:
jvm-server.options
jvm11-server.options
among others.
What will be the order they are loaded in? Am I correct in understanding that the last one overrides the next to last and so on?
I've looked at the Cassandra documentation re jvm-*
files, I've looked at the cassandra-env.sh
file as well, and in the cassandra
file in /usr/sbin
and couldn't understand the order. I'm seeing the files in the original Github so surely the all serve some purpose but I just can't figure out how they come together.
Could I decypher this from the run command I found via pgrep -af cassandra
? Is this a general Java thing or a Cassandra thing?
So if we have a look at the code in the cassandra.in.sh file (for version 4.1), we can see this at the bottom:
# 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
JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm11${jvmoptions_variant:--clients}.options
else
JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm8${jvmoptions_variant:--clients}.options
fi
for opt in `grep "^-" $JVM_OPTS_FILE` `grep "^-" $JVM_DEP_OPTS_FILE`
do
JVM_OPTS="$JVM_OPTS $opt"
done
Actually, if we cd
into the conf/
directory, we can use a modified version of that for loop:
for opt in `grep "^-" jvm-server.options` `grep "^-" jvm11-server.options`
do
echo $opt
done
...this will let you see the order that each of the JVM options from those files will be applied in.
So yes, if there are conflicting JVM options set between the two files, the jvm11-server.options
file will win-out.