Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 167 lines (137 sloc) 5.056 kb
0ae8217 Update Rakefile to use cassandra.in.sh.
Robert Jackson authored
1 require 'fileutils'
2
b6ce6d6 Handy script to install the server.
Evan Weaver authored
3 unless ENV['FROM_BIN_CASSANDRA_HELPER']
4 require 'rubygems'
5 require 'echoe'
345fff2 New Cassandra build, and package task.
Evan Weaver authored
6
b6ce6d6 Handy script to install the server.
Evan Weaver authored
7 Echoe.new("cassandra") do |p|
508f9b5 Manifest.
Evan Weaver authored
8 p.author = "Evan Weaver, Ryan King"
b6ce6d6 Handy script to install the server.
Evan Weaver authored
9 p.project = "fauna"
10 p.summary = "A Ruby client for the Cassandra distributed database."
11 p.rubygems_version = ">= 0.8"
e6c4899 Fix typo in simple_uuid dependency.
Robert Jackson authored
12 p.dependencies = ['thrift_client >=0.7.0', 'json', 'rake', 'simple_uuid >=0.2.0']
997cfd0 Add back .gemspec. Fixes issue #86.
Robert Jackson authored
13 p.ignore_pattern = /^(data|vendor\/cassandra|cassandra|vendor\/thrift|.*\.rbc)/
b6ce6d6 Handy script to install the server.
Evan Weaver authored
14 p.rdoc_pattern = /^(lib|bin|tasks|ext)|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
997cfd0 Add back .gemspec. Fixes issue #86.
Robert Jackson authored
15 p.retain_gemspec = true
b6ce6d6 Handy script to install the server.
Evan Weaver authored
16 end
0bc3e40 Rakefile checkouts, patches, and builds Cassandra.
Evan Weaver authored
17 end
18
e6ba300 Enable multiple Cassandra server versions.
Robert Jackson authored
19 CassandraBinaries = {
475fd74 Use archive.apache.org for binaries. (Download link stays active inde…
Robert Jackson authored
20 '0.6' => 'http://archive.apache.org/dist/cassandra/0.6.13/apache-cassandra-0.6.13-bin.tar.gz',
21 '0.7' => 'http://archive.apache.org/dist/cassandra/0.7.8/apache-cassandra-0.7.8-bin.tar.gz',
1020d08 Update Rakefile and README to reference 0.8.4.
Robert Jackson authored
22 '0.8' => 'http://archive.apache.org/dist/cassandra/0.8.4/apache-cassandra-0.8.4-bin.tar.gz'
e6ba300 Enable multiple Cassandra server versions.
Robert Jackson authored
23 }
24
8a1ffca @bierbaum Allow alternate CASSANDRA_HOME through an environment variable
bierbaum authored
25 CASSANDRA_HOME = ENV['CASSANDRA_HOME'] || "#{ENV['HOME']}/cassandra"
9ffb26b Make 0.8 the default Cassandra version.
Robert Jackson authored
26 CASSANDRA_VERSION = ENV['CASSANDRA_VERSION'] || '0.8'
1d44218 Add cassandra:start and :stop Rake tasks.
Robert Jackson authored
27 CASSANDRA_PIDFILE = ENV['CASSANDRA_PIDFILE'] || "#{CASSANDRA_HOME}/cassandra.pid"
b6ce6d6 Handy script to install the server.
Evan Weaver authored
28
e6ba300 Enable multiple Cassandra server versions.
Robert Jackson authored
29 def setup_cassandra_version(version = CASSANDRA_VERSION)
0ae8217 Update Rakefile to use cassandra.in.sh.
Robert Jackson authored
30 FileUtils.mkdir_p CASSANDRA_HOME
31
34f0163 Setup conf directories for each version.
Robert Jackson authored
32 destination_directory = File.join(CASSANDRA_HOME, 'cassandra-' + CASSANDRA_VERSION)
e6ba300 Enable multiple Cassandra server versions.
Robert Jackson authored
33
34 unless File.exists?(File.join(destination_directory, 'bin','cassandra'))
0ae8217 Update Rakefile to use cassandra.in.sh.
Robert Jackson authored
35 download_source = CassandraBinaries[CASSANDRA_VERSION]
36 download_destination = File.join("/tmp", File.basename(download_source))
37 untar_directory = File.join(CASSANDRA_HOME, File.basename(download_source,'-bin.tar.gz'))
38
e6ba300 Enable multiple Cassandra server versions.
Robert Jackson authored
39 puts "downloading cassandra"
40 sh "curl -L -o #{download_destination} #{download_source}"
41
42 sh "tar xzf #{download_destination} -C #{CASSANDRA_HOME}"
0ae8217 Update Rakefile to use cassandra.in.sh.
Robert Jackson authored
43 sh "mv #{untar_directory} #{destination_directory}"
e6ba300 Enable multiple Cassandra server versions.
Robert Jackson authored
44 end
45 end
46
3dbcd4e Add cli Rake task.
Robert Jackson authored
47 def setup_environment
e31c84a Fix issue with setup_environment in Rakefile.
Robert Jackson authored
48 env = ""
b6ce6d6 Handy script to install the server.
Evan Weaver authored
49 if !ENV["CASSANDRA_INCLUDE"]
0ae8217 Update Rakefile to use cassandra.in.sh.
Robert Jackson authored
50 env << "CASSANDRA_INCLUDE=#{File.expand_path(Dir.pwd)}/conf/#{CASSANDRA_VERSION}/cassandra.in.sh "
34f0163 Setup conf directories for each version.
Robert Jackson authored
51 env << "CASSANDRA_HOME=#{CASSANDRA_HOME}/cassandra-#{CASSANDRA_VERSION} "
52 env << "CASSANDRA_CONF=#{File.expand_path(Dir.pwd)}/conf/#{CASSANDRA_VERSION}"
52e4224 @ryanking configuration updates
ryanking authored
53 else
54 env << "CASSANDRA_INCLUDE=#{ENV['CASSANDRA_INCLUDE']} "
55 env << "CASSANDRA_HOME=#{ENV['CASSANDRA_HOME']} "
56 env << "CASSANDRA_CONF=#{ENV['CASSANDRA_CONF']}"
08ab8cf Re-apply 75a5ed26f8ed269769c592249571edbe6ef7bf31.
Evan Weaver authored
57 end
ba8527d @ryanking move from using git to http for getting a server
ryanking authored
58
3dbcd4e Add cli Rake task.
Robert Jackson authored
59 env
60 end
61
1d44218 Add cassandra:start and :stop Rake tasks.
Robert Jackson authored
62 def running?(pid_file = nil)
63 pid_file ||= CASSANDRA_PIDFILE
3dbcd4e Add cli Rake task.
Robert Jackson authored
64
1d44218 Add cassandra:start and :stop Rake tasks.
Robert Jackson authored
65 if File.exists?(pid_file)
66 pid = File.new(pid_file).read.to_i
67 begin
68 Process.kill(0, pid)
69 return true
70 rescue
71 File.delete(pid_file)
72 end
73 end
0ae8217 Update Rakefile to use cassandra.in.sh.
Robert Jackson authored
74
1d44218 Add cassandra:start and :stop Rake tasks.
Robert Jackson authored
75 false
76 end
0ae8217 Update Rakefile to use cassandra.in.sh.
Robert Jackson authored
77
1d44218 Add cassandra:start and :stop Rake tasks.
Robert Jackson authored
78 namespace :cassandra do
79 desc "Start Cassandra"
ed4c539 Fix rake task dependency deprecation.
Robert Jackson authored
80 task :start, [:daemonize] => :java do |t, args|
1d44218 Add cassandra:start and :stop Rake tasks.
Robert Jackson authored
81 args.with_defaults(:daemonize => true)
82
83 setup_cassandra_version
84
85 env = setup_environment
86
87 Dir.chdir(File.join(CASSANDRA_HOME, "cassandra-#{CASSANDRA_VERSION}")) do
88 sh("env #{env} bin/cassandra #{'-f' unless args.daemonize} -p #{CASSANDRA_PIDFILE}")
89 end
90 end
91
92 desc "Stop Cassandra"
93 task :stop => :java do
94 setup_cassandra_version
95 env = setup_environment
96 sh("kill $(cat #{CASSANDRA_PIDFILE})")
ba8527d @ryanking move from using git to http for getting a server
ryanking authored
97 end
98 end
99
1d44218 Add cassandra:start and :stop Rake tasks.
Robert Jackson authored
100 desc "Start Cassandra"
101 task :cassandra => :java do
23c08a2 Handle interrupt when cassandra task is canceled.
Robert Jackson authored
102 begin
103 Rake::Task["cassandra:start"].invoke(false)
104 rescue RuntimeError => e
105 raise e unless e.message =~ /Command failed with status \(130\)/ # handle keyboard interupt errors
ba8527d @ryanking move from using git to http for getting a server
ryanking authored
106 end
107 end
108
3dbcd4e Add cli Rake task.
Robert Jackson authored
109 desc "Run the Cassandra CLI"
110 task :cli do
111 Dir.chdir(File.join(CASSANDRA_HOME, "cassandra-#{CASSANDRA_VERSION}")) do
112 sh("bin/cassandra-cli -host localhost -port 9160")
113 end
114 end
ba8527d @ryanking move from using git to http for getting a server
ryanking authored
115
b87c4f4 Check Java version.
Evan Weaver authored
116 desc "Check Java version"
117 task :java do
118 unless `java -version 2>&1`.split("\n").first =~ /java version "1.6/ #"
1ba06e5 Better build error reporting.
Evan Weaver authored
119 puts "You need to configure your environment for Java 1.6."
b87c4f4 Check Java version.
Evan Weaver authored
120 puts "If you're on OS X, just export the following environment variables:"
121 puts ' JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"'
122 puts ' PATH="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin:$PATH"'
123 exit(1)
124 end
125 end
126
b6ce6d6 Handy script to install the server.
Evan Weaver authored
127 namespace :data do
128 desc "Reset test data"
129 task :reset do
76b05df Re-use same checkout folder from now on.
Evan Weaver authored
130 puts "Resetting test data"
476af55 Update 0.7 schema.txt.
Robert Jackson authored
131 sh("rm -rf #{File.join(CASSANDRA_HOME, "cassandra-#{CASSANDRA_VERSION}", 'data')}")
132 end
133
134 desc "Load test data structures."
135 task :load do
3099f1a Skip loading the schema on 0.6.
Robert Jackson authored
136 unless CASSANDRA_VERSION == '0.6'
137
138 schema_path = "#{File.expand_path(Dir.pwd)}/conf/#{CASSANDRA_VERSION}/schema.txt"
139 puts "Loading test data structures."
140 Dir.chdir(File.join(CASSANDRA_HOME, "cassandra-#{CASSANDRA_VERSION}")) do
141 begin
142 sh("bin/cassandra-cli --host localhost --batch < #{schema_path}")
143 rescue
144 puts "Schema already loaded."
145 end
6da343d @ryanking minor cleanups to rakefile
ryanking authored
146 end
476af55 Update 0.7 schema.txt.
Robert Jackson authored
147 end
b6ce6d6 Handy script to install the server.
Evan Weaver authored
148 end
0bc3e40 Rakefile checkouts, patches, and builds Cassandra.
Evan Weaver authored
149 end
150
6da343d @ryanking minor cleanups to rakefile
ryanking authored
151 task :test => 'data:load'
152
1ba06e5 Better build error reporting.
Evan Weaver authored
153 # desc "Regenerate thrift bindings for Cassandra" # Dev only
e49622b Update quickstart. Update thrift bindings.
Evan Weaver authored
154 task :thrift do
76b05df Re-use same checkout folder from now on.
Evan Weaver authored
155 puts "Generating Thrift bindings"
e49622b Update quickstart. Update thrift bindings.
Evan Weaver authored
156 system(
157 "cd vendor &&
158 rm -rf gen-rb &&
3fd5c59 @b Update with latest Thrift (for real) and add keyspace and cf wrapper …
b authored
159 thrift -gen rb #{CASSANDRA_HOME}/interface/cassandra.thrift")
0bc3e40 Rakefile checkouts, patches, and builds Cassandra.
Evan Weaver authored
160 end
4c3f613 @ryanking fix permissions
ryanking authored
161
162 task :fix_perms do
163 chmod_R 0755, './'
164 end
165
f87dc5e @ryanking Merge branch 'master' of github.com:fauna/cassandra
ryanking authored
166 task :pkg => [:fix_perms]
Something went wrong with that request. Please try again.