Permalink
Browse files

Handy script to install the server.

  • Loading branch information...
1 parent eba0ecb commit b6ce6d6536a3cedeb9df42c4978e14c3d002ca3c Evan Weaver committed Aug 18, 2009
Showing with 85 additions and 41 deletions.
  1. +0 −2 .gitignore
  2. +2 −0 CHANGELOG
  3. +1 −0 Manifest
  4. +6 −4 README
  5. +56 −24 Rakefile
  6. +16 −0 bin/cassandra_helper
  7. +4 −11 conf/cassandra.in.sh
View
@@ -1,2 +0,0 @@
-cassandra
-data
View
@@ -1,4 +1,6 @@
+v0.5.1. Add bin/cassandra script, to build and start the server for you.
+
v0.5. More API changes. Working temporal comparators.
v0.4. Use new comparator API. Namespace Thrift bindings; rename gem and class to Cassandra. Make tokens and limits actually work. Retry UnavailableExceptions.
View
@@ -1,3 +1,4 @@
+bin/cassandra_helper
CHANGELOG
conf/cassandra.in.sh
conf/log4j.properties
View
10 README
@@ -25,12 +25,14 @@ You need Ruby 1.8 or 1.9. If you have those, just run:
sudo gem install cassandra
-== Usage
-
-Cassandra is a rapidly moving target. In order to get a working server, change to the checkout or gem directory, and run:
+Cassandra is a rapidly moving target. In order to get a working server, use the <tt>bin/cassandra_helper</tt> script (requires <tt>git</tt>):
- rake cassandra
+ cassandra_helper cassandra
+
+A server will be installed in <tt>$HOME/cassandra/r$REVISION</tt>, and started in debug mode.
+== Usage
+
Now, start IRb and require the library:
require 'cassandra'
View
@@ -1,68 +1,100 @@
-require 'echoe'
-Echoe.new("cassandra") do |p|
- p.author = "Evan Weaver"
- p.project = "fauna"
- p.summary = "A Ruby client for the Cassandra distributed database."
- p.rubygems_version = ">= 0.8"
- p.dependencies = ['json', 'thrift']
- p.ignore_pattern = /^(data|vendor\/cassandra|cassandra|vendor\/thrift)/
- p.rdoc_pattern = /^(lib|bin|tasks|ext)|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
- p.url = "http://blog.evanweaver.com/files/doc/fauna/cassandra/"
- p.docs_host = "blog.evanweaver.com:~/www/bax/public/files/doc/"
-end
+unless ENV['FROM_BIN_CASSANDRA_HELPER']
+ require 'rubygems'
+ require 'echoe'
-desc "Start Cassandra"
-task :cassandra => [:checkout, :patch, :build] do
- env = "CASSANDRA_INCLUDE=#{Dir.pwd}/conf/cassandra.in.sh" unless ENV["CASSANDRA_INCLUDE"]
- exec("env #{env} cassandra/bin/cassandra -f")
+ Echoe.new("cassandra") do |p|
+ p.author = "Evan Weaver"
+ p.project = "fauna"
+ p.summary = "A Ruby client for the Cassandra distributed database."
+ p.rubygems_version = ">= 0.8"
+ p.dependencies = ['json', 'thrift']
+ p.ignore_pattern = /^(data|vendor\/cassandra|cassandra|vendor\/thrift)/
+ p.rdoc_pattern = /^(lib|bin|tasks|ext)|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
+ p.url = "http://blog.evanweaver.com/files/doc/fauna/cassandra/"
+ p.docs_host = "blog.evanweaver.com:~/www/bax/public/files/doc/"
+ end
end
REVISION = "15354b4906fd654d58fe50fd01ebf95b69434ba9"
+
PATCHES = [
"http://issues.apache.org/jira/secure/attachment/12416014/0001-CASSANDRA-356-rename-clean-up-collectColumns-methods.txt",
"http://issues.apache.org/jira/secure/attachment/12416073/0002-v3.patch",
"http://issues.apache.org/jira/secure/attachment/12416074/357-v2.patch",
"http://issues.apache.org/jira/secure/attachment/12416086/357-3.patch"]
-
+
+CASSANDRA_HOME = "#{ENV['HOME']}/cassandra/r#{REVISION[0, 8]}"
+
+CASSANDRA_TEST = "#{ENV['HOME']}/cassandra/test"
+
+desc "Start Cassandra"
+task :cassandra => [:checkout, :patch, :build] do
+ # Construct environment
+ env = ""
+ if !ENV["CASSANDRA_INCLUDE"]
+ env << "CASSANDRA_INCLUDE=#{Dir.pwd}/conf/cassandra.in.sh "
+ env << "CASSANDRA_HOME=#{CASSANDRA_HOME} "
+ env << "CASSANDRA_CONF=#{File.expand_path(File.dirname(__FILE__))}/conf"
+ end
+ # Create data dir
+ Dir.mkdir(CASSANDRA_TEST) if !File.exist?(CASSANDRA_TEST)
+ # Start server
+ Dir.chdir(CASSANDRA_TEST) do
+ exec("env #{env} #{CASSANDRA_HOME}/bin/cassandra -f")
+ end
+end
+
+desc "Checkout Cassandra from git"
task :checkout do
# Like a git submodule, but all in one obvious place
- unless File.exist?("cassandra")
- system("git clone git://git.apache.org/cassandra.git")
+ unless File.exist?(CASSANDRA_HOME)
+ system("git clone git://git.apache.org/cassandra.git #{CASSANDRA_HOME}")
ENV["RESET"] = "true"
end
end
+desc "Apply patches to Cassandra checkout"
task :patch do
if ENV["RESET"]
- Dir.chdir("cassandra") do
+ system("rm -rf #{CASSANDRA_TEST}/data")
+ Dir.chdir(CASSANDRA_HOME) do
system("ant clean && git fetch && git reset #{REVISION} --hard")
# Delete untracked files, so that the patchs can apply again
Array(`git status`[/Untracked files:(.*)$/m, 1].to_s.split("\n")[3..-1]).each do |file|
File.unlink(file.sub(/^.\s+/, "")) rescue nil
end
# Patch, with a handy commit for each one
- PATCHES.each do |url|
+ PATCHES.each do |url|
raise "#{url} failed" unless system("curl #{url} | patch -p1")
system("git commit -a -m 'Applied patch: #{url.inspect}'")
end
end
end
end
+desc "Rebuild Cassandra"
task :build do
- Dir.chdir("cassandra") { system("ant") } unless File.exist?("cassandra/build")
+ Dir.chdir(CASSANDRA_HOME) { system("ant") } unless File.exist?("#{CASSANDRA_HOME}/build")
end
+desc "Clean Cassandra build"
task :clean do
- Dir.chdir("cassandra") { system("ant clean") }
+ Dir.chdir(CASSANDRA_HOME) { system("ant clean") } if File.exist?(CASSANDRA_HOME)
+end
+
+namespace :data do
+ desc "Reset test data"
+ task :reset do
+ system("rm -rf #{CASSANDRA_TEST}/data")
+ end
end
desc "Regenerate thrift bindings for Cassandra"
task :thrift do
system(
"cd vendor &&
rm -rf gen-rb &&
- thrift -gen rb ../cassandra/interface/cassandra.thrift")
+ thrift -gen rb #{CASSANDRA_HOME}/interface/cassandra.thrift")
end
View
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'rake'
+require 'cassandra'
+
+gem_path = $LOAD_PATH.last.sub(/lib$/, "")
+
+Dir.chdir(gem_path) do
+ if !ENV["CASSANDRA_INCLUDE"]
+ puts "Set the CASSANDRA_INCLUDE environment variable to use a non-default cassandra.in.sh and friends."
+ end
+
+ ARGV << "-T" if ARGV.empty?
+ exec("env FROM_BIN_CASSANDRA_HELPER=1 rake #{ARGV.join(' ')}")
+end
View
@@ -14,27 +14,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
-cassandra_home=`pwd`/cassandra
-
# The directory where Cassandra's configs live (required)
-CASSANDRA_CONF=`pwd`/conf
+CASSANDRA_CONF=$CASSANDRA_CONF
# 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
-#cassandra_bin=$cassandra_home/build/cassandra.jar
+# compiled classes.
+cassandra_bin=$CASSANDRA_HOME/build/classes
# The java classpath (required)
CLASSPATH=$CASSANDRA_CONF:$cassandra_bin
-for jar in $cassandra_home/lib/*.jar; do
+for jar in $CASSANDRA_HOME/lib/*.jar; do
CLASSPATH=$CLASSPATH:$jar
done
-echo $cassandra_home
-
# Arguments to pass to the JVM
JVM_OPTS=" \
-ea \

0 comments on commit b6ce6d6

Please sign in to comment.