diff --git a/CHANGES.txt b/CHANGES.txt index 69b2ecae81..6e4ee0a460 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -207,6 +207,7 @@ * Add the ability to disable bulk loading of SSTables (CASSANDRA-18781) * Clean up obsolete functions and simplify cql_version handling in cqlsh (CASSANDRA-18787) Merged from 5.0: + * Do not source cassandra-env.sh unnecessarily in nodetool and other tooling (CASSANDRA-20745) * Make source distribution buildable by ant artifacts as doc/scripts/process-native-protocol-specs-in-docker.sh was not executable (CASSANDRA-20802) * SSTableIndexWriter#abort() should log more quietly in cases where an exception is not provided (CASSANDRA-20695) * Avoid availability gap between UP and queryability marking for already built SAI indexes on bounce (CASSANDRA-20732) diff --git a/bin/nodetool b/bin/nodetool index 6ba19e16f0..4ca496b4ea 100755 --- a/bin/nodetool +++ b/bin/nodetool @@ -43,20 +43,21 @@ if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then exit 1 fi -# Run cassandra-env.sh to pick up JMX_PORT +JMX_PORT="" + +# Try to parse port from configure_jmx method call, when not commented out if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then - JVM_OPTS_SAVE=$JVM_OPTS - MAX_HEAP_SIZE_SAVE=$MAX_HEAP_SIZE - . "$CASSANDRA_CONF/cassandra-env.sh" - MAX_HEAP_SIZE=$MAX_HEAP_SIZE_SAVE - JVM_OPTS="$JVM_OPTS_SAVE" + jmx_method_call=$(grep "^configure_jmx \+[0-9]\+$" "$CASSANDRA_CONF/cassandra-env.sh") + if [ ! "x${jmx_method_call}" = "x" ]; then + JMX_PORT=$(echo "${jmx_method_call}" | tr -s " " | cut -d " " -f2) + fi fi # In case JMX_PORT is not set (when configure_jmx in cassandra-env.sh is commented out), # try to parse it from cassandra.yaml. if [ "x$JMX_PORT" = "x" ]; then if [ -f "$CASSANDRA_CONF/cassandra.yaml" ]; then - JMX_PORT=`grep jmx_port $CASSANDRA_CONF/cassandra.yaml | cut -d ':' -f 2 | tr -d '[[:space:]]'` + JMX_PORT=$(grep jmx_port "$CASSANDRA_CONF/cassandra.yaml" | cut -d ':' -f 2 | tr -d '[[:space:]]') fi fi @@ -111,6 +112,11 @@ if [ "x$MAX_HEAP_SIZE" = "x" ]; then MAX_HEAP_SIZE="128m" fi +# Sets the path where logback and GC logs are written. +if [ "x$CASSANDRA_LOG_DIR" = "x" ] ; then + CASSANDRA_LOG_DIR="$CASSANDRA_HOME/logs" +fi + CMD=$(echo "$JAVA" $JAVA_AGENT -ea -cp "$CLASSPATH" $JVM_OPTS -Xmx$MAX_HEAP_SIZE \ -XX:ParallelGCThreads=1 \ -Dcassandra.storagedir="$cassandra_storagedir" \ diff --git a/conf/cassandra-env.sh b/conf/cassandra-env.sh index 8bbf4a592d..50e273517f 100644 --- a/conf/cassandra-env.sh +++ b/conf/cassandra-env.sh @@ -291,8 +291,8 @@ configure_jmx() # We will be expecting the settings in jmx_server_options and jmx_encryption_options respectively instead. # The argument specifies the default port over which Cassandra will be available for JMX connections. # -# If you comment out configure_jmx method call, then JMX_PORT variable will not be set, which means -# nodetool which sources this file will not see it either and port from cassandra.yaml will be parsed instead, +# If you comment out configure_jmx method call, then the port argument of configure_jmx function will not be used +# when nodetool parses this file and port from cassandra.yaml will be parsed instead, # if not found there either, it defaults to 7199. # # For security reasons, you should not expose this port to the internet. Firewall it if needed. diff --git a/tools/bin/fqltool b/tools/bin/fqltool index dc49e50246..dd4a395615 100755 --- a/tools/bin/fqltool +++ b/tools/bin/fqltool @@ -37,17 +37,6 @@ if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then exit 1 fi -# Run cassandra-env.sh to pick up JMX_PORT -if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then - JVM_OPTS_SAVE=$JVM_OPTS - MAX_HEAP_SIZE_SAVE=$MAX_HEAP_SIZE - . "$CASSANDRA_CONF/cassandra-env.sh" - MAX_HEAP_SIZE=$MAX_HEAP_SIZE_SAVE - JVM_OPTS=$JVM_OPTS_SAVE -fi - -# JMX Port passed via cmd line args (-p 9999 / --port 9999 / --port=9999) -# should override the value from cassandra-env.sh ARGS="" JVM_ARGS="" while true diff --git a/tools/bin/jmxtool b/tools/bin/jmxtool index b46305c08f..b2372c2db5 100755 --- a/tools/bin/jmxtool +++ b/tools/bin/jmxtool @@ -37,17 +37,6 @@ if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then exit 1 fi -# Run cassandra-env.sh to pick up JMX_PORT -if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then - JVM_OPTS_SAVE=$JVM_OPTS - MAX_HEAP_SIZE_SAVE=$MAX_HEAP_SIZE - . "$CASSANDRA_CONF/cassandra-env.sh" - MAX_HEAP_SIZE=$MAX_HEAP_SIZE_SAVE - JVM_OPTS=$JVM_OPTS_SAVE -fi - -# JMX Port passed via cmd line args (-p 9999 / --port 9999 / --port=9999) -# should override the value from cassandra-env.sh ARGS="" JVM_ARGS="" while true