Permalink
Browse files

fixed readme, added solandra, removed star-solandra.sh, moved solandr…

…a.in.sh to env -
  • Loading branch information...
1 parent f9fa215 commit 93563562bc07d1ff7534a2437849e0f15138e74c @ceocoder ceocoder committed Jun 9, 2011
Showing with 188 additions and 130 deletions.
  1. +0 −1 .gitignore
  2. +1 −1 README.md
  3. +11 −10 resources/{solandra.in.sh → cassandra/cassandra-env.sh}
  4. +176 −0 resources/cassandra/solandra
  5. +0 −118 resources/start-solandra.sh
View
@@ -8,6 +8,5 @@ solandra-app/
*.war
/target
/solandra
-cassandra/
.DS_Store
reuters-demo/data/*
View
@@ -29,7 +29,7 @@ From the Solandra base directory:
mkdir /tmp/cassandra-data
ant
- cd solandra-app; ./start-solandra.sh
+ cd solandra-app; bin/solandra
Now that Solandra is running you can run the demo:
@@ -20,11 +20,13 @@ calculate_heap_sizes()
Linux)
system_memory_in_mb=`free -m | awk '/Mem:/ {print $2}'`
system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo`
+ break
;;
FreeBSD)
system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'`
system_memory_in_mb=$((system_memory_in_bytes / 1024 / 1024))
system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
+ break
;;
*)
# assume reasonable defaults for e.g. a modern desktop or
@@ -79,13 +81,7 @@ fi
# Specifies the default port over which Cassandra will be available for
# JMX connections.
-JMX_PORT="8080"
-
-# To use mx4j, an HTML interface for JMX, add mx4j-tools.jar to the lib/ directory.
-# By default mx4j listens on 0.0.0.0:8081. Uncomment the following lines to control
-# its listen address and port.
-#MX4J_ADDRESS="-Dmx4jaddress=0.0.0.0"
-#MX4J_PORT="-Dmx4jport=8081"
+JMX_PORT="7199"
# Here we create the arguments that will get passed to the jvm when
@@ -95,6 +91,13 @@ JMX_PORT="8080"
# performance benefit (around 5%).
JVM_OPTS="$JVM_OPTS -ea"
+# add the jamm javaagent
+check_openjdk=$(java -version 2>&1 | awk '{if (NR == 2) {print $1}}')
+if [ "$check_openjdk" != "OpenJDK" ]
+then
+ JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-0.2.2.jar"
+fi
+
# enable thread priorities, primarily so we can give periodic tasks
# a lower priority to avoid interfering with client workload
JVM_OPTS="$JVM_OPTS -XX:+UseThreadPriorities"
@@ -134,7 +137,7 @@ JVM_OPTS="$JVM_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
# JVM_OPTS="$JVM_OPTS -XX:+PrintClassHistogram"
# JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution"
# JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"
-# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc.log"
+# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc-`date +%s`.log"
# uncomment to have Cassandra JVM listen for remote debuggers/profilers on port 1414
# JVM_OPTS="$JVM_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1414"
@@ -156,5 +159,3 @@ JVM_OPTS="$JVM_OPTS -Djava.net.preferIPv4Stack=true"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
-JVM_OPTS="$JVM_OPTS $MX4J_ADDRESS"
-JVM_OPTS="$JVM_OPTS $MX4J_PORT"
@@ -0,0 +1,176 @@
+#!/bin/sh
+# 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.
+
+
+# OPTIONS:
+# -f: start in foreground
+# -p <filename>: log the pid to a file (useful to kill it later)
+# -v: print version string and exit
+
+# CONTROLLING STARTUP:
+#
+# This script relies on few environment variables to determine startup
+# behavior, those variables are:
+#
+# CLASSPATH -- A Java classpath containing everything necessary to run.
+# JVM_OPTS -- Additional arguments to the JVM for heap size, etc
+# CASSANDRA_CONF -- Directory containing Cassandra configuration files.
+#
+# As a convenience, a fragment of shell is sourced in order to set one or
+# more of these variables. This so-called `include' can be placed in a
+# number of locations and will be searched for in order. The lowest
+# priority search path is the same directory as the startup script, and
+# since this is the location of the sample in the project tree, it should
+# almost work Out Of The Box.
+#
+# Any serious use-case though will likely require customization of the
+# include. For production installations, it is recommended that you copy
+# the sample to one of /usr/share/cassandra/cassandra.in.sh,
+# /usr/local/share/cassandra/cassandra.in.sh, or
+# /opt/cassandra/cassandra.in.sh and make your modifications there.
+#
+# Another option is to specify the full path to the include file in the
+# environment. For example:
+#
+# $ CASSANDRA_INCLUDE=/path/to/in.sh cassandra -p /var/run/cass.pid
+#
+# Note: This is particularly handy for running multiple instances on a
+# single installation, or for quick tests.
+#
+# Finally, developers and enthusiasts who frequently run from an SVN
+# checkout, and do not want to locally modify bin/cassandra.in.sh, can put
+# a customized include file at ~/.cassandra.in.sh.
+#
+# If you would rather configure startup entirely from the environment, you
+# can disable the include by exporting an empty CASSANDRA_INCLUDE, or by
+# ensuring that no include files exist in the aforementioned search list.
+# Be aware that you will be entirely responsible for populating the needed
+# environment variables.
+
+# If an include wasn't specified in the environment, then search for one...
+if [ "x$CASSANDRA_INCLUDE" = "x" ]; then
+ # Locations (in order) to use when searching for an include file.
+ for include in /usr/share/cassandra/cassandra.in.sh \
+ /usr/local/share/cassandra/cassandra.in.sh \
+ /opt/cassandra/cassandra.in.sh \
+ ~/.cassandra.in.sh \
+ `dirname $0`/cassandra.in.sh; do
+ if [ -r $include ]; then
+ . $include
+ break
+ fi
+ done
+# ...otherwise, source the specified include.
+elif [ -r $CASSANDRA_INCLUDE ]; then
+ . $CASSANDRA_INCLUDE
+fi
+
+# Use JAVA_HOME if set, otherwise look for java in PATH
+if [ -x $JAVA_HOME/bin/java ]; then
+ JAVA=$JAVA_HOME/bin/java
+else
+ JAVA=`which java`
+fi
+
+if [ -z $CASSANDRA_CONF -o -z $CLASSPATH ]; then
+ echo "You must set the CASSANDRA_CONF and CLASSPATH vars" >&2
+ exit 1
+fi
+
+if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then
+ . "$CASSANDRA_CONF/cassandra-env.sh"
+fi
+
+# Special-case path variables.
+case "`uname`" in
+ CYGWIN*)
+ CLASSPATH=`cygpath -p -w "$CLASSPATH"`
+ CASSANDRA_CONF=`cygpath -p -w "$CASSANDRA_CONF"`
+ ;;
+esac
+
+launch_service()
+{
+ pidpath=$1
+ foreground=$2
+ props=$3
+ class=$4
+ cassandra_parms="-Dlog4j.configuration=log4j-tools.properties -Dlog4j.defaultInitOverride=true"
+
+ if [ "x$pidpath" != "x" ]; then
+ cassandra_parms="$cassandra_parms -Dcassandra-pidfile=$pidpath"
+ fi
+
+ # The cassandra-foreground option will tell CassandraDaemon not
+ # to close stdout/stderr, but it's up to us not to background.
+ if [ "x$foreground" != "x" ]; then
+ cassandra_parms="$cassandra_parms -Dcassandra-foreground=yes"
+ exec $JAVA $JVM_OPTS $cassandra_parms -cp $CLASSPATH $props $class
+ # Startup CassandraDaemon, background it, and write the pid.
+ else
+ exec $JAVA $JVM_OPTS $cassandra_parms -cp $CLASSPATH $props $class <&- &
+ [ ! -z $pidpath ] && printf "%d" $! > $pidpath
+ fi
+
+ return $?
+}
+
+# Parse any command line options.
+args=`getopt vfhp:bD: "$@"`
+eval set -- "$args"
+
+classname="solandra.SolandraServer"
+
+while true; do
+ case "$1" in
+ -p)
+ pidfile="$2"
+ shift 2
+ ;;
+ -f)
+ foreground="yes"
+ shift
+ ;;
+ -h)
+ echo "Usage: $0 [-f] [-h] [-p pidfile]"
+ exit 0
+ ;;
+ -v)
+ $JAVA -cp $CLASSPATH org.apache.cassandra.tools.GetVersion
+ exit 0
+ ;;
+ -D)
+ properties="$properties -D$2"
+ shift 2
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Error parsing arguments!" >&2
+ exit 1
+ ;;
+ esac
+done
+
+# Start up the service
+launch_service "$pidfile" "$foreground" "$properties" "$classname"
+
+exit $?
+
+# vi:ai sw=4 ts=4 tw=0 et
View
@@ -1,118 +0,0 @@
-#!/bin/sh
-
-# 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$SOLANDRA_INCLUDE" = "x" ]; then
- for include in /usr/share/solandra/solandra.in.sh \
- /usr/local/share/solandra/solandra.in.sh \
- /opt/solandra/solandra.in.sh \
- ~/.solandra.in.sh \
- `dirname $0`/solandra.in.sh; do
- if [ -r $include ]; then
- . $include
- break
- fi
- done
-elif [ -r $SOLANDRA_INCLUDE ]; then
- . $SOLANDRA_INCLUDE
-fi
-
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x $JAVA_HOME/bin/java ]; then
- JAVA=$JAVA_HOME/bin/java
-else
- JAVA=`which java`
-fi
-
-
-# Parse any command line options.
-args=`getopt fchdp:bD: "$@"`
-eval set -- "$args"
-
-while true; do
- case "$1" in
- -p)
- pidfile="$2"
- shift 2
- ;;
- -f)
- foreground="yes"
- shift
- ;;
- -h)
- echo "Usage: $0 [-f] [-h] [-c] [-d] [-p pidfile]"
- echo " -f : run in foreground"
- echo " -h : prints this help message"
- echo " -c : starts solandra in client mode"
- echo " -d : enables debuging port and logs to the foreground"
- exit 0
- ;;
- -c)
- properties="$properties -Dsolandra.clientmode=true"
- shift
- ;;
- -d)
- debug="yes"
- shift
- ;;
- -D)
- properties="$properties -D$2"
- shift 2
- ;;
- --)
- shift
- break
- ;;
- *)
- echo "Error parsing arguments! $1 $2" >&2
- exit 1
- ;;
- esac
-done
-
-#boostrap schema?
-if [ "x$schema" != "x" ]
-then
- foreground=""
- debug=""
-fi
-
-#debug mode?
-if [ "x$debug" != "x" ]
-then
- foreground="yes"
- JVM_OPTS="$JVM_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044"
-else
- LOGGING="etc/jetty-logging.xml"
-fi
-
-if [ "x$pidpath" != "x" ]; then
- solandra_parms="$solandra_parms -Dcassandra-pidfile=$pidpath"
-fi
-
-solandra_parms="$solandra_parms -Dlog4j.configuration=log4j.properties -Dlog4j.defaultInitOverride=true $properties"
-
-# The solandra-foreground option will tell Cassandra not
-# to close stdout/stderr, but it's up to us not to background.
-if [ "x$foreground" != "x" ]; then
- solandra_parms="$solandra_parms -Dcassandra-foreground=yes"
- exec $JAVA $JVM_OPTS $solandra_parms -jar start.jar $LOGGING etc/jetty.xml
-# Startup Solandra, background it, and write the pid.
-else
- exec $JAVA $JVM_OPTS $solandra_parms -jar start.jar $LOGGING etc/jetty.xml <&- &
- [ ! -z $pidfile ] && printf "%d" $! > $pidfile
-fi

0 comments on commit 9356356

Please sign in to comment.