Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (42 sloc) 1.439 kb
c78468b @jakedouglas blam
authored
1 require 'rubygems'
2 require 'spec/rake/spectask'
3 require 'lib/cassandra_lock'
4
5 task :default => :spec
6
7 Spec::Rake::SpecTask.new(:spec) do |t|
8 t.spec_opts = ["--colour --format=nested --backtrace"]
9 t.spec_files = Dir['spec/*.rb'].sort
10 end
11
12 task :reset_keyspace do
13 if Cassandra.VERSION < "0.7"
14 raise "Need Cassandra 0.7 to manipulate keyspaces"
15 end
16
17 keyspace = ENV['KEYSPACE'] || "CassandraLock"
18 host = ENV['HOST'] || "127.0.0.1:9160"
19 rf = ENV['RF'] || "1"
20
21 puts "Using values:"
22 puts "KEYSPACE: #{keyspace}"
23 puts "HOST: #{host}"
24 puts "RF: #{rf}"
25 puts "Dropping and re-adding keyspace..."
26
27 c = Cassandra.new("system", host, :timeout => 5)
28 c.drop_keyspace(keyspace) rescue nil
29
30 CassandraLock.keyspace = keyspace
31
32 ks_def = Cassandra::Keyspace.new(:name => keyspace,
33 :strategy_class => "org.apache.cassandra.locator.RackUnawareStrategy",
34 :replication_factor => rf.to_i,
214ede2 @jakedouglas Store lock data in a Super CF to eliminate a read
authored
35 :cf_defs => [CassandraLock.cf_def])
c78468b @jakedouglas blam
authored
36
37 c.add_keyspace(ks_def)
38
39 puts "Done"
40 end
41
214ede2 @jakedouglas Store lock data in a Super CF to eliminate a read
authored
42 task :reset_cf do
c78468b @jakedouglas blam
authored
43 keyspace = ENV['KEYSPACE'] || "CassandraLock"
44 host = ENV['HOST'] || "127.0.0.1:9160"
45
46 puts "Using values:"
47 puts "KEYSPACE: #{keyspace}"
48 puts "HOST: #{host}"
214ede2 @jakedouglas Store lock data in a Super CF to eliminate a read
authored
49 puts "Resetting lock CF..."
c78468b @jakedouglas blam
authored
50
51 CassandraLock.keyspace = keyspace
52 CassandraLock.host = host
214ede2 @jakedouglas Store lock data in a Super CF to eliminate a read
authored
53 CassandraLock.reset_cf!
c78468b @jakedouglas blam
authored
54
55 puts "Done"
56 end
Something went wrong with that request. Please try again.