Blob Blame History Raw
diff -urN cassandra-3.9/bin/cassandra cassandra-3.9new/bin/cassandra
--- cassandra-3.9/bin/cassandra	2016-09-26 16:02:27.000000000 +0200
+++ cassandra-3.9new/bin/cassandra	2017-02-07 16:56:54.216604418 +0100
@@ -115,13 +115,13 @@
     NUMACTL=""
 fi
 
-if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then
-    echo "You must set the CASSANDRA_CONF and CLASSPATH vars" >&2
+if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" -o -z "$CASSANDRA_HOME" ]; then
+    echo "You must set the CASSANDRA_CONF, CASSANDRA_HOME and CLASSPATH vars" >&2
     exit 1
 fi
 
-if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then
-    . "$CASSANDRA_CONF/cassandra-env.sh"
+if [ -f "/usr/share/$CASSANDRA_HOME/cassandra-env.sh" ]; then
+    . "/usr/share/$CASSANDRA_HOME/cassandra-env.sh"
 fi
 
 # Special-case path variables.
@@ -188,7 +188,7 @@
     props="$3"
     class="$4"
     cassandra_parms="-Dlogback.configurationFile=logback.xml"
-    cassandra_parms="$cassandra_parms -Dcassandra.logdir=$CASSANDRA_HOME/logs"
+    cassandra_parms="$cassandra_parms -Dcassandra.logdir=/var/log/$CASSANDRA_HOME"
     cassandra_parms="$cassandra_parms -Dcassandra.storagedir=$cassandra_storagedir"
 
     if [ "x$pidpath" != "x" ]; then
@@ -210,6 +210,19 @@
     return $?
 }
 
+wait_for_service_available()
+{
+  host=$(cat $CASSANDRA_CONF/cassandra.yaml | grep listen_address: | head -1 | cut -d' ' -f2)
+  port=$(cat $CASSANDRA_CONF/cassandra.yaml | grep native_transport_port | head -1 | cut -d' ' -f2)
+  if ! nc -z $host $port; then
+    # echo "Waiting for Cassandra to start..."
+    while ! nc -z $host $port; do
+       sleep 1
+    done
+    # echo "Cassandra is ready."
+  fi
+}
+
 # Parse any command line options.
 args=`getopt vRfhp:bD:H:E: "$@"`
 eval set -- "$args"
@@ -283,6 +296,14 @@
 # Start up the service
 launch_service "$pidfile" "$foreground" "$properties" "$classname"
 
-exit $?
+ret=$?
+
+if [ 0$ret -ne "0" ]; then
+    exit $ret
+fi
+
+wait_for_service_available
+
+exit 0
 
 # vi:ai sw=4 ts=4 tw=0 et
diff -urN cassandra-3.9/bin/cassandra.in.sh cassandra-3.9new/bin/cassandra.in.sh
--- cassandra-3.9/bin/cassandra.in.sh	2016-09-26 16:02:27.000000000 +0200
+++ cassandra-3.9new/bin/cassandra.in.sh	2017-02-06 14:48:03.221172120 +0100
@@ -1,3 +1,4 @@
+#!/bin/bash
 # 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
@@ -15,62 +16,54 @@
 # limitations under the License.
 
 if [ "x$CASSANDRA_HOME" = "x" ]; then
-    CASSANDRA_HOME="`dirname "$0"`/.."
+    CASSANDRA_HOME="cassandra"
 fi
 
 # The directory where Cassandra's configs live (required)
 if [ "x$CASSANDRA_CONF" = "x" ]; then
-    CASSANDRA_CONF="$CASSANDRA_HOME/conf"
+    CASSANDRA_CONF="/etc/$CASSANDRA_HOME"
 fi
 
-# This can be the path to a jar file, or a directory containing the 
-# compiled classes. NOTE: This isn't needed by the startup script,
-# it's just used here in constructing the classpath.
-cassandra_bin="$CASSANDRA_HOME/build/classes/main"
-cassandra_bin="$cassandra_bin:$CASSANDRA_HOME/build/classes/thrift"
-#cassandra_bin="$CASSANDRA_HOME/build/cassandra.jar"
-
 # the default location for commitlogs, sstables, and saved caches
 # if not set in cassandra.yaml
-cassandra_storagedir="$CASSANDRA_HOME/data"
-
-# JAVA_HOME can optionally be set here
-#JAVA_HOME=/usr/local/jdk6
+cassandra_storagedir="/var/lib/$CASSANDRA_HOME/data"
 
 # The java classpath (required)
-CLASSPATH="$CASSANDRA_CONF:$cassandra_bin"
+CLASSPATH="$CASSANDRA_CONF"
 
-for jar in "$CASSANDRA_HOME"/lib/*.jar; do
-    CLASSPATH="$CLASSPATH:$jar"
-done
+DEPS=( cassandra/cassandra-all metrics slf4j/api guava snakeyaml commons-codec jackson/jackson-mapper-asl jackson/jackson-core-asl netty/netty-all lz4 logback/logback-classic logback/logback-core jna sigar high-scale-lib/high-scale-lib antlr3-runtime concurrentlinkedhashmap-lru commons-lang3 json_simple stream-lib caffeine cassandra/cassandra-thrift libthrift snappy-java jBCrypt jctools )
 
-# JSR223 - collect all JSR223 engines' jars
-for jsr223jar in "$CASSANDRA_HOME"/lib/jsr223/*/*.jar; do
-    CLASSPATH="$CLASSPATH:$jsr223jar"
+for dep in "${DEPS[@]}"; do
+    CLASSPATH="$CLASSPATH:`build-classpath $dep`"
 done
-# JSR223/JRuby - set ruby lib directory
-if [ -d "$CASSANDRA_HOME"/lib/jsr223/jruby/ruby ] ; then
-    export JVM_OPTS="$JVM_OPTS -Djruby.lib=$CASSANDRA_HOME/lib/jsr223/jruby"
-fi
-# JSR223/JRuby - set ruby JNI libraries root directory
-if [ -d "$CASSANDRA_HOME"/lib/jsr223/jruby/jni ] ; then
-    export JVM_OPTS="$JVM_OPTS -Djffi.boot.library.path=$CASSANDRA_HOME/lib/jsr223/jruby/jni"
-fi
-# JSR223/Jython - set python.home system property
-if [ -f "$CASSANDRA_HOME"/lib/jsr223/jython/jython.jar ] ; then
-    export JVM_OPTS="$JVM_OPTS -Dpython.home=$CASSANDRA_HOME/lib/jsr223/jython"
-fi
-# JSR223/Scala - necessary system property
-if [ -f "$CASSANDRA_HOME"/lib/jsr223/scala/scala-compiler.jar ] ; then
-    export JVM_OPTS="$JVM_OPTS -Dscala.usejavacp=true"
-fi
 
 # set JVM javaagent opts to avoid warnings/errors
 if [ "$JVM_VENDOR" != "OpenJDK" -o "$JVM_VERSION" \> "1.6.0" ] \
       || [ "$JVM_VERSION" = "1.6.0" -a "$JVM_PATCH_VERSION" -ge 23 ]
 then
-    JAVA_AGENT="$JAVA_AGENT -javaagent:$CASSANDRA_HOME/lib/jamm-0.3.0.jar"
+    JAVA_AGENT="$JAVA_AGENT -javaagent:`build-classpath jamm`"
 fi
 
-# Added sigar-bin to the java.library.path CASSANDRA-7838
-JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
+java_ver_output=`"${JAVA:-java}" -version 2>&1`
+jvm=`echo "$java_ver_output" | grep -A 1 'version' | awk 'NR==2 {print $1}'`
+case "$jvm" in
+    OpenJDK)
+        # this will be "64-Bit" or "32-Bit"
+        JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'`
+        ;;
+    "Java(TM)")
+        # this will be "64-Bit" or "32-Bit"
+        JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'`
+        ;;
+    *)
+        # Help fill in other JVM values
+        JVM_ARCH=unknown
+        ;;
+esac
+
+# Added libsigar.so to the java.library.path CASSANDRA-7838
+if [ "$JVM_ARCH" = "64-Bit" ]; then
+    JVM_OPTS="$JVM_OPTS -Djava.library.path=/usr/lib64:/usr/lib64/sigar"
+else
+    JVM_OPTS="$JVM_OPTS -Djava.library.path=/usr/lib:/usr/lib/sigar"
+fi
diff -urN cassandra-3.9/bin/cqlsh.py cassandra-3.9new/bin/cqlsh.py
--- cassandra-3.9/bin/cqlsh.py	2016-09-26 16:02:27.000000000 +0200
+++ cassandra-3.9new/bin/cqlsh.py	2017-01-25 14:27:45.843304664 +0100
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/python
 # -*- mode: Python -*-
 
 # Licensed to the Apache Software Foundation (ASF) under one
@@ -17,18 +17,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-""":"
-# bash code here; finds a suitable python interpreter and execs this file.
-# prefer unqualified "python" if suitable:
-python -c 'import sys; sys.exit(not (0x020700b0 < sys.hexversion < 0x03000000))' 2>/dev/null \
-    && exec python "$0" "$@"
-for pyver in 2.7; do
-    which python$pyver > /dev/null 2>&1 && exec python$pyver "$0" "$@"
-done
-echo "No appropriate python interpreter found." >&2
-exit 1
-":"""
-
 from __future__ import with_statement
 
 import cmd
diff -urN cassandra-3.9/bin/nodetool cassandra-3.9new/bin/nodetool
--- cassandra-3.9/bin/nodetool	2016-09-26 16:02:27.000000000 +0200
+++ cassandra-3.9new/bin/nodetool	2017-02-07 14:13:01.593406756 +0100
@@ -24,11 +24,11 @@
 
 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
+    for include in "`dirname "$0"`/nodetool.in.sh" \
+                   "$HOME/.nodetool.in.sh" \
+                   /usr/share/cassandra/nodetool.in.sh \
+                   /usr/local/share/cassandra/nodetool.in.sh \
+                   /opt/cassandra/nodetool.in.sh; do
         if [ -r "$include" ]; then
             . "$include"
             break
@@ -50,15 +50,15 @@
     exit 1
 fi
 
-if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then
-    echo "You must set the CASSANDRA_CONF and CLASSPATH vars" >&2
+if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" -o -z "$CASSANDRA_HOME" ]; then
+    echo "You must set the CASSANDRA_CONF, $CASSANDRA_HOME and CLASSPATH vars" >&2
     exit 1
 fi
 
 # Run cassandra-env.sh to pick up JMX_PORT
-if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then
+if [ -f "/usr/share/$CASSANDRA_HOME/cassandra-env.sh" ]; then
     JVM_OPTS_SAVE=$JVM_OPTS
-    . "$CASSANDRA_CONF/cassandra-env.sh"
+    . "/usr/share/$CASSANDRA_HOME/cassandra-env.sh"
     JVM_OPTS=$JVM_OPTS_SAVE
 fi
 
diff -urN cassandra-3.9/bin/nodetool.in.sh cassandra-3.9new/bin/nodetool.in.sh
--- cassandra-3.9/bin/nodetool.in.sh	1970-01-01 01:00:00.000000000 +0100
+++ cassandra-3.9new/bin/nodetool.in.sh	2017-01-26 16:43:54.866218781 +0100
@@ -0,0 +1,38 @@
+# 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.
+
+if [ "x$CASSANDRA_HOME" = "x" ]; then
+    CASSANDRA_HOME="cassandra"
+fi
+
+# The directory where Cassandra's configs live (required)
+if [ "x$CASSANDRA_CONF" = "x" ]; then
+    CASSANDRA_CONF="/etc/$CASSANDRA_HOME"
+fi
+
+# the default location for commitlogs, sstables, and saved caches
+# if not set in cassandra.yaml
+cassandra_storagedir="/var/lib/$CASSANDRA_HOME/data"
+
+# The java classpath (required)
+CLASSPATH="$CASSANDRA_CONF"
+
+DEPS=( airline cassandra/cassandra-all guava javax.inject slf4j/api jackson/jackson-mapper-asl jackson/jackson-core-asl logback/logback-classic logback/logback-core commons-lang3 high-scale-lib/high-scale-lib antlr3-runtime metrics concurrentlinkedhashmap-lru snakeyaml commons-codec )
+
+for dep in "${DEPS[@]}"; do
+    CLASSPATH="$CLASSPATH:`build-classpath $dep`"
+done
+
diff -urN cassandra-3.9/conf/cassandra-env.sh cassandra-3.9new/conf/cassandra-env.sh
--- cassandra-3.9/conf/cassandra-env.sh	2016-09-26 16:02:27.000000000 +0200
+++ cassandra-3.9new/conf/cassandra-env.sh	2017-01-25 14:28:12.372505772 +0100
@@ -1,3 +1,4 @@
+#!/bin/bash
 # 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
@@ -88,21 +89,17 @@
 
 # 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%_*}
-JVM_PATCH_VERSION=${jvmver#*_}
+jvmver=`echo "$java_ver_output" | grep '[openjdk|java] version' | awk -F'"' 'NR==1 {print $2}'`
+tmp=(${jvmver//_/ })
+JVM_VERSION="${tmp[0]}"
+JVM_PATCH_VERSION="${tmp[1]}"
 
-if [ "$JVM_VERSION" \< "1.8" ] ; then
+if [ "$JVM_VERSION" \< "1.8" ] || [ "$JVM_PATCH_VERSION" -lt 40 ] ; then
     echo "Cassandra 3.0 and later require Java 8u40 or later."
     exit 1;
 fi
 
-if [ "$JVM_VERSION" \< "1.8" ] && [ "$JVM_PATCH_VERSION" -lt 40 ] ; then
-    echo "Cassandra 3.0 and later require Java 8u40 or later."
-    exit 1;
-fi
-
-jvm=`echo "$java_ver_output" | grep -A 1 'java version' | awk 'NR==2 {print $1}'`
+jvm=`echo "$java_ver_output" | grep -A 1 'version' | awk 'NR==2 {print $1}'`
 case "$jvm" in
     OpenJDK)
         JVM_VENDOR=OpenJDK
@@ -122,7 +119,7 @@
 esac
 
 #GC log path has to be defined here because it needs to access CASSANDRA_HOME
-JVM_OPTS="$JVM_OPTS -Xloggc:${CASSANDRA_HOME}/logs/gc.log"
+JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/$CASSANDRA_HOME/gc.log"
 
 # Here we create the arguments that will get passed to the jvm when
 # starting cassandra.
@@ -207,7 +204,7 @@
 JVM_OPTS="$JVM_OPTS -XX:CompileCommandFile=$CASSANDRA_CONF/hotspot_compiler"
 
 # add the jamm javaagent
-JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-0.3.0.jar"
+JVM_OPTS="$JVM_OPTS -javaagent:`build-classpath jamm`"
 
 # set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR
 if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then
@@ -271,7 +268,7 @@
 ## which delegates to the IAuthenticator configured in cassandra.yaml. See the sample JAAS configuration
 ## file cassandra-jaas.config
 #JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.remote.login.config=CassandraLogin"
-#JVM_OPTS="$JVM_OPTS -Djava.security.auth.login.config=$CASSANDRA_HOME/conf/cassandra-jaas.config"
+#JVM_OPTS="$JVM_OPTS -Djava.security.auth.login.config=/etc/$CASSANDRA_HOME/cassandra-jaas.config"
 
 ## Cassandra also ships with a helper for delegating JMX authz calls to the configured IAuthorizer,
 ## uncomment this to use it. Requires one of the two authentication options to be enabled
@@ -288,7 +285,12 @@
 # Cassandra uses SIGAR to capture OS metrics CASSANDRA-7838
 # for SIGAR we have to set the java.library.path
 # to the location of the native libraries.
-JVM_OPTS="$JVM_OPTS -Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
+if [ "$JVM_ARCH" = "64-Bit" ]; then
+    JVM_OPTS="$JVM_OPTS -Djava.library.path=/usr/lib64:/usr/lib64/sigar"
+else
+    JVM_OPTS="$JVM_OPTS -Djava.library.path=/usr/lib:/usr/lib/sigar"
+fi
+
 
 JVM_OPTS="$JVM_OPTS $MX4J_ADDRESS"
 JVM_OPTS="$JVM_OPTS $MX4J_PORT"
diff -urN cassandra-3.9/tools/bin/cassandra-stress cassandra-3.9new/tools/bin/cassandra-stress
--- cassandra-3.9/tools/bin/cassandra-stress	2016-09-26 16:02:27.000000000 +0200
+++ cassandra-3.9new/tools/bin/cassandra-stress	2017-01-25 14:33:56.608115288 +0100
@@ -49,6 +49,8 @@
     exit 1
 fi
 
+CLASSPATH="$CLASSPATH:`build-classpath cassandra-stress`"
+
 "$JAVA" -server -ea -cp "$CLASSPATH" $JVM_OPTS \
         -Dcassandra.storagedir="$cassandra_storagedir" \
         -Dlogback.configurationFile=logback-tools.xml \
diff -urN cassandra-3.9/tools/bin/cassandra-stressd cassandra-3.9new/tools/bin/cassandra-stressd
--- cassandra-3.9/tools/bin/cassandra-stressd	2016-09-26 16:02:27.000000000 +0200
+++ cassandra-3.9new/tools/bin/cassandra-stressd	2017-01-25 14:34:00.190142443 +0100
@@ -50,6 +50,8 @@
     exit 1
 fi
 
+CLASSPATH="$CLASSPATH:`build-classpath cassandra-stress`"
+
 case "$1" in
   start)
     echo "Starting $DESC: "