Claudenw commented on code in PR #1950:
URL: https://github.com/apache/cassandra/pull/1950#discussion_r1112053251
##########
bin/nodetool:
##########
@@ -22,35 +22,8 @@ if [ "`basename "$0"`" = 'nodeprobe' ]; then
echo "***************************************************************" >&2
fi
-if [ "x$CASSANDRA_INCLUDE" = "x" ]; then
- # Locations (in order) to use when searching for an include file.
- for include in "`dirname "$0"`/cassandra.in.sh" \
- "$HOME/.cassandra.in.sh" \
- /usr/share/cassandra/cassandra.in.sh \
- /usr/local/share/cassandra/cassandra.in.sh \
- /opt/cassandra/cassandra.in.sh; do
- if [ -r "$include" ]; then
- . "$include"
- break
- fi
- done
-elif [ -r "$CASSANDRA_INCLUDE" ]; then
- . "$CASSANDRA_INCLUDE"
-fi
-
-if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then
- echo "You must set the CASSANDRA_CONF and CLASSPATH vars" >&2
- 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
+ENV_PRESERVE="$ENV_PRESERVE MAX_HEAP_SIZE JVM_OPTS"
+. ./cassandra-conf.sh
Review Comment:
`cassandra_conf.sh` pulls the common code from all the existing scripts.
This is found at:
https://github.com/apache/cassandra/pull/1950/files#diff-61e866313476b2b21fa3d88d315567447c43de4f55066776bc649d9f898b3bf6R105-R140
also lines 151-153 and 165-167
nodetool then has special requirements to unset some vars so it needs to
preserve and reset some around the cassandra-env.sh call.
the script `cassandra.in.sh`
- can move and is located by various means.
- sets CASSANDRA_HOME and CASSANDRA_CONF if not set.
- sets JAVA_AGENT, CLASSPATH, JVM_OPTS, JVM_DEP_OPTS, and JAVA_VERSION
- is a file that may be edited by users to change the configuration.
so `cassandra_conf.sh` should not move. It should always be in the same
directory with the script(s) loading it.
any script using `cassandra_conf.sh` will have the lines
```. ./cassandra-conf.sh
validate_env
```
some, like `nodetool` my preserve vars and so set `CASSANDRA_ENV_PRESERVE`
with a list of variables to preserve.
some like `nodetool` may set additional vars for which debugging display is
appropriate. Those will list the additional env vars after the `validate_env`
as `nodetool` does
```
validate_env JMX_PORT
```
Simply put `cassandra_conf.sh` removes the boilerplate from the scripts to
create one place where all the configuration determination is performed, it has
hooks to support current operations (like `nodetool`), it adds debugging of the
environment variables to make problem determination easier and consistent
across all the script based tooling.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]