forked from cassandra-rb/cassandra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Evan Weaver
committed
Aug 18, 2009
1 parent
eba0ecb
commit b6ce6d6
Showing
7 changed files
with
85 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
cassandra | ||
data | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
bin/cassandra_helper | ||
CHANGELOG | ||
conf/cassandra.in.sh | ||
conf/log4j.properties | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters