cassandra 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.8.2 Renamed :thrift_client_class option, UUID fix, 0.6 update, fixing cassanda install, much Mock fixes
2
+
1
3
  v0.8.1 Adding the ability to compose ThriftClient classes.
2
4
 
3
5
  v0.8.0 Compatibility with Cassandra 0.6 betas (no longer compatible with 0.5); assorted bugfixes.
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ end
17
17
 
18
18
  CASSANDRA_HOME = ENV['CASSANDRA_HOME'] || "#{ENV['HOME']}/cassandra"
19
19
  DOWNLOAD_DIR = "/tmp"
20
- DIST_URL = "http://apache.osuosl.org/incubator/cassandra/0.6.0/apache-cassandra-0.6.0-beta2-bin.tar.gz"
20
+ DIST_URL = "http://mirrors.kahuki.com/apache/cassandra/0.6.0/apache-cassandra-0.6.0-rc1-bin.tar.gz"
21
21
  DIST_FILE = DIST_URL.split('/').last
22
22
 
23
23
  directory CASSANDRA_HOME
@@ -39,11 +39,8 @@ end
39
39
 
40
40
  file File.join(CASSANDRA_HOME, 'server') => File.join(DOWNLOAD_DIR, DIST_FILE) do
41
41
  Dir.chdir(CASSANDRA_HOME) do
42
- sh "tar xzf #{DIST_FILE}"
42
+ sh "tar xzf #{File.join(DOWNLOAD_DIR, DIST_FILE)} -C #{CASSANDRA_HOME}"
43
43
  sh "mv #{DIST_FILE.split('.')[0..2].join('.').sub('-bin', '')} server"
44
- Dir.chdir('server') do
45
- sh "ant ivy-retrieve"
46
- end
47
44
  end
48
45
  end
49
46
 
data/cassandra.gemspec CHANGED
@@ -2,12 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{cassandra}
5
- s.version = "0.8.1"
5
+ s.version = "0.8.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0.8") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Evan Weaver, Ryan King"]
9
- s.cert_chain = ["/Users/ryan/.gemkeys/gem-public_cert.pem"]
10
- s.date = %q{2010-03-30}
9
+ s.date = %q{2010-04-13}
11
10
  s.default_executable = %q{cassandra_helper}
12
11
  s.description = %q{A Ruby client for the Cassandra distributed database.}
13
12
  s.email = %q{}
@@ -18,8 +17,7 @@ Gem::Specification.new do |s|
18
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Cassandra", "--main", "README.rdoc"]
19
18
  s.require_paths = ["lib"]
20
19
  s.rubyforge_project = %q{fauna}
21
- s.rubygems_version = %q{1.3.5}
22
- s.signing_key = %q{/Users/ryan/.gemkeys/gem-private_key.pem}
20
+ s.rubygems_version = %q{1.3.6}
23
21
  s.summary = %q{A Ruby client for the Cassandra distributed database.}
24
22
  s.test_files = ["test/cassandra_client_test.rb", "test/cassandra_mock_test.rb", "test/cassandra_test.rb", "test/comparable_types_test.rb", "test/eventmachine_test.rb", "test/ordered_hash_test.rb", "test/test_helper.rb"]
25
23
 
@@ -64,6 +64,7 @@
64
64
  <ColumnFamily CompareWith="UTF8Type" Name="StatusAudits" />
65
65
  <ColumnFamily CompareWith="UTF8Type" CompareSubcolumnsWith="TimeUUIDType" ColumnType="Super" Name="StatusRelationships" />
66
66
  <ColumnFamily CompareWith="UTF8Type" ColumnType="Super" Name="Index" />
67
+ <ColumnFamily CompareWith="BytesType" ColumnType="Standard" Name="TimelinishThings" />
67
68
 
68
69
  <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
69
70
  <ReplicationFactor>1</ReplicationFactor>
@@ -154,12 +155,12 @@
154
155
  ~ disk. Keep the data disks and the CommitLog disks separate for best
155
156
  ~ performance
156
157
  -->
157
- <CommitLogDirectory>/var/lib/cassandra/commitlog</CommitLogDirectory>
158
+ <CommitLogDirectory>data/cassandra/commitlog</CommitLogDirectory>
158
159
  <DataFileDirectories>
159
- <DataFileDirectory>/var/lib/cassandra/data</DataFileDirectory>
160
+ <DataFileDirectory>data/cassandra/data</DataFileDirectory>
160
161
  </DataFileDirectories>
161
- <CalloutLocation>/var/lib/cassandra/callouts</CalloutLocation>
162
- <StagingFileDirectory>/var/lib/cassandra/staging</StagingFileDirectory>
162
+ <CalloutLocation>data/cassandra/callouts</CalloutLocation>
163
+ <StagingFileDirectory>data/cassandra/staging</StagingFileDirectory>
163
164
 
164
165
 
165
166
  <!--
data/lib/cassandra.rb CHANGED
@@ -2,7 +2,6 @@ require 'rubygems'
2
2
  require 'thrift_client'
3
3
  require 'json' unless defined?(JSON)
4
4
  require 'simple_uuid'
5
- include SimpleUUID
6
5
  here = File.expand_path(File.dirname(__FILE__))
7
6
 
8
7
  $LOAD_PATH << "#{here}/../vendor/gen-rb"
@@ -6,7 +6,7 @@ Create a new Cassandra client instance. Accepts a keyspace name, and optional ho
6
6
 
7
7
  You can then make calls to the server via the <tt>client</tt> instance.
8
8
 
9
- client.insert(:UserRelationships, "5", {"user_timeline" => {UUID.new => "1"}})
9
+ client.insert(:UserRelationships, "5", {"user_timeline" => {SimpleUUID::UUID.new => "1"}})
10
10
  client.get(:UserRelationships, "5", "user_timeline")
11
11
 
12
12
  For read methods, valid option parameters are:
@@ -66,12 +66,17 @@ class Cassandra
66
66
  @is_super = {}
67
67
  @column_name_class = {}
68
68
  @sub_column_name_class = {}
69
+ @auto_discover_nodes = true
69
70
  @thrift_client_options = THRIFT_DEFAULTS.merge(thrift_client_options)
70
71
  @thrift_client_class = @thrift_client_options[:thrift_client_class]
71
72
  @keyspace = keyspace
72
73
  @servers = Array(servers)
73
74
  end
74
75
 
76
+ def disable_node_auto_discovery!
77
+ @auto_discover_nodes = false
78
+ end
79
+
75
80
  def disconnect!
76
81
  @client.disconnect!
77
82
  @client = nil
@@ -293,9 +298,13 @@ class Cassandra
293
298
  end
294
299
 
295
300
  def all_nodes
296
- ips = ::JSON.parse(new_client.get_string_property('token map')).values
297
- port = @servers.first.split(':').last
298
- ips.map{|ip| "#{ip}:#{port}" }
301
+ if @auto_discover_nodes
302
+ ips = ::JSON.parse(new_client.get_string_property('token map')).values
303
+ port = @servers.first.split(':').last
304
+ ips.map{|ip| "#{ip}:#{port}" }
305
+ else
306
+ @servers
307
+ end
299
308
  end
300
309
 
301
310
  end
@@ -21,7 +21,7 @@ class Cassandra
21
21
  property =~ /.*\.(.*?)$/
22
22
  case $1
23
23
  when "LongType" then Long
24
- when "LexicalUUIDType", "TimeUUIDType" then UUID
24
+ when "LexicalUUIDType", "TimeUUIDType" then SimpleUUID::UUID
25
25
  else
26
26
  String # UTF8, Ascii, Bytes, anything else
27
27
  end
@@ -5,7 +5,6 @@ class Cassandra
5
5
  module Constants
6
6
  include Cassandra::Consistency
7
7
 
8
- UUID = Cassandra::UUID
9
8
  Long = Cassandra::Long
10
9
  OrderedHash = Cassandra::OrderedHash
11
10
  end
@@ -5,13 +5,13 @@ class Cassandra
5
5
  column_family = column_family.to_s
6
6
  # Keys
7
7
  [keys].flatten.each do |key|
8
- raise ArgumentError, "Key #{key.inspect} must be a String for #{calling_method}" unless key.is_a?(String)
8
+ raise ArgumentError, "Key #{key.inspect} must be a String for #{caller[2].inspect}." unless key.is_a?(String)
9
9
  end
10
10
 
11
11
  # Options
12
12
  if args.last.is_a?(Hash)
13
13
  extras = args.last.keys - options.keys
14
- raise ArgumentError, "Invalid options #{extras.inspect[1..-2]} for #{calling_method}" if extras.any?
14
+ raise ArgumentError, "Invalid options #{extras.inspect[1..-2]} for #{caller[1]}" if extras.any?
15
15
  options.merge!(args.pop)
16
16
  end
17
17
 
@@ -1,6 +1,6 @@
1
1
  require 'nokogiri'
2
2
 
3
- class UUID
3
+ class SimpleUUID::UUID
4
4
  def >=(other)
5
5
  (self <=> other) >= 0
6
6
  end
@@ -34,35 +34,31 @@ class Cassandra
34
34
  @data[column_family.to_sym] = OrderedHash.new
35
35
  end
36
36
 
37
- def insert(column_family, key, hash, options = {})
37
+ def insert(column_family, key, hash_or_array, options = {})
38
38
  if @batch
39
- @batch << [:insert, column_family, key, hash, options]
39
+ @batch << [:insert, column_family, key, hash_or_array, options]
40
40
  else
41
41
  raise ArgumentError if key.nil?
42
42
  if column_family_type(column_family) == 'Standard'
43
- insert_standard(column_family, key, hash)
43
+ insert_standard(column_family, key, hash_or_array)
44
44
  else
45
- insert_super(column_family, key, hash)
45
+ insert_super(column_family, key, hash_or_array)
46
46
  end
47
47
  end
48
48
  end
49
49
 
50
- def insert_standard(column_family, key, hash)
51
- if cf(column_family)[key]
52
- cf(column_family)[key] = merge_and_sort(cf(column_family)[key], hash)
53
- else
54
- cf(column_family)[key] = OrderedHash[hash.sort{|a,b| a[0] <=> b[0]}]
55
- end
50
+ def insert_standard(column_family, key, hash_or_array)
51
+ old = cf(column_family)[key] || OrderedHash.new
52
+ cf(column_family)[key] = merge_and_sort(old, hash_or_array)
56
53
  end
57
54
 
58
55
  def insert_super(column_family, key, hash)
56
+ raise ArgumentError unless hash.is_a?(Hash)
59
57
  cf(column_family)[key] ||= OrderedHash.new
58
+
60
59
  hash.keys.each do |sub_key|
61
- if cf(column_family)[key][sub_key]
62
- cf(column_family)[key][sub_key] = merge_and_sort(cf(column_family)[key][sub_key], hash[sub_key])
63
- else
64
- cf(column_family)[key][sub_key] = OrderedHash[hash[sub_key].sort{|a,b| a[0] <=> b[0]}]
65
- end
60
+ old = cf(column_family)[key][sub_key] || OrderedHash.new
61
+ cf(column_family)[key][sub_key] = merge_and_sort(old, hash[sub_key])
66
62
  end
67
63
  end
68
64
 
@@ -244,7 +240,7 @@ class Cassandra
244
240
  if cf['CompareWith']
245
241
  ret[cf['Name']]['CompareWith'] = 'org.apache.cassandra.db.marshal.' + cf['CompareWith']
246
242
  end
247
- if cf['ColumnType']
243
+ if cf['ColumnType'] == 'Super'
248
244
  ret[cf['Name']]['Type'] = 'Super'
249
245
  else
250
246
  ret[cf['Name']]['Type'] = 'Standard'
@@ -283,15 +279,14 @@ class Cassandra
283
279
  end
284
280
 
285
281
  case klass
286
- when "org.apache.cassandra.db.marshal.UTF8Type"
282
+ when "org.apache.cassandra.db.marshal.UTF8Type", "org.apache.cassandra.db.marshal.BytesType"
287
283
  column_name
288
284
  when "org.apache.cassandra.db.marshal.TimeUUIDType"
289
- UUID.new(column_name)
285
+ SimpleUUID::UUID.new(column_name)
290
286
  when "org.apache.cassandra.db.marshal.LongType"
291
287
  Long.new(column_name)
292
288
  else
293
- p klass
294
- raise
289
+ raise "Unknown column family type: #{klass.inspect}"
295
290
  end
296
291
  end
297
292
 
@@ -304,6 +299,9 @@ class Cassandra
304
299
  end
305
300
 
306
301
  def merge_and_sort(old_stuff, new_stuff)
302
+ if new_stuff.is_a?(Array)
303
+ new_stuff = new_stuff.inject({}){|h,k| h[k] = nil; h }
304
+ end
307
305
  OrderedHash[old_stuff.merge(new_stuff).sort{|a,b| a[0] <=> b[0]}]
308
306
  end
309
307
 
@@ -321,4 +319,4 @@ class Cassandra
321
319
  end
322
320
  end
323
321
  end
324
- end
322
+ end
@@ -16,7 +16,7 @@ class CassandraMockTest < CassandraTest
16
16
  @blogs_long = Cassandra::Mock.new('MultiblogLong', storage_xml_path)
17
17
  @blogs_long.clear_keyspace!
18
18
 
19
- @uuids = (0..6).map {|i| UUID.new(Time.at(2**(24+i))) }
19
+ @uuids = (0..6).map {|i| SimpleUUID::UUID.new(Time.at(2**(24+i))) }
20
20
  @longs = (0..6).map {|i| Long.new(Time.at(2**(24+i))) }
21
21
  end
22
22
 
@@ -45,7 +45,9 @@ class CassandraMockTest < CassandraTest
45
45
  "UserAudits"=>{
46
46
  "CompareWith"=>"org.apache.cassandra.db.marshal.UTF8Type",
47
47
  "Type"=>"Standard"},
48
- "Users"=>{"CompareWith"=>"org.apache.cassandra.db.marshal.UTF8Type", "Type"=>"Standard"}
48
+ "Users"=>{"CompareWith"=>"org.apache.cassandra.db.marshal.UTF8Type", "Type"=>"Standard"},
49
+ "TimelinishThings"=>
50
+ {"CompareWith"=>"org.apache.cassandra.db.marshal.BytesType", "Type"=>"Standard"}
49
51
  }
50
52
  stuff = @twitter.send(:schema_for_keyspace, 'Twitter')
51
53
  data.keys.each do |k|
@@ -58,4 +60,14 @@ class CassandraMockTest < CassandraTest
58
60
  @twitter.insert(:Statuses, 'a', {:text => 'foo'})
59
61
  assert_equal ['a'], @twitter.get_range(:Statuses, :count => 1)
60
62
  end
63
+
64
+ def test_inserting_array_for_indices
65
+ @twitter.insert(:TimelinishThings, 'a', ['1','2'])
66
+ row = @twitter.get(:TimelinishThings, 'a')
67
+ assert_equal({'1' => nil, '2' => nil}, row)
68
+
69
+ assert_raises(ArgumentError) {
70
+ @twitter.insert(:UserRelationships, 'a', ['u1','u2'])
71
+ }
72
+ end
61
73
  end
@@ -13,7 +13,7 @@ class CassandraTest < Test::Unit::TestCase
13
13
  @blogs_long = Cassandra.new('MultiblogLong')
14
14
  @blogs_long.clear_keyspace!
15
15
 
16
- @uuids = (0..6).map {|i| UUID.new(Time.at(2**(24+i))) }
16
+ @uuids = (0..6).map {|i| SimpleUUID::UUID.new(Time.at(2**(24+i))) }
17
17
  @longs = (0..6).map {|i| Long.new(Time.at(2**(24+i))) }
18
18
  end
19
19
 
metadata CHANGED
@@ -1,78 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassandra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 8
8
+ - 2
9
+ version: 0.8.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Evan Weaver, Ryan King
8
13
  autorequire:
9
14
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMQ0wCwYDVQQDDARyeWFu
14
- MRswGQYKCZImiZPyLGQBGRYLdGhlcnlhbmtpbmcxEzARBgoJkiaJk/IsZAEZFgNj
15
- b20wHhcNMTAwMTA4MTc1MDM0WhcNMTEwMTA4MTc1MDM0WjBBMQ0wCwYDVQQDDARy
16
- eWFuMRswGQYKCZImiZPyLGQBGRYLdGhlcnlhbmtpbmcxEzARBgoJkiaJk/IsZAEZ
17
- FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLPp+0PtRT3qCI
18
- 02sMsADSn7Uf1GpyXUtk4Fb94LqUO6Scl91YDmbFMpjzrQwQvBYMIVreWcwSish6
19
- nip6WEk9lqXcOeDmex/qY2/FVXG8ffqjFHiNiN9vpWrWj5VMICequ+ftzWLKsPIS
20
- DGJ4o+Z6wEYRuirgaRPCYAUDPglsaqctJ56wPuycryMe5+ApSkOS9iLWMprQKEAq
21
- j2R2OBV0dSARdbtzuKwrP7sLDo7uPa0egFBUlcZ+nujGr4LvmpryB8scNRNmZK1w
22
- 1rEI7O06CbULj08qYxEhnKmFE7LbBoN/HrmvZLVQK5mWuiZQhtmJuhBfStJsaDux
23
- 5tBEkYZVAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
24
- BBSnLarDEo5eBE2arSMrBdOOhtrnPTANBgkqhkiG9w0BAQUFAAOCAQEANER07s4K
25
- Pvc1DSduliRDMUax/VSfLzDTtTAQwuSAPDrWAYXKugcJtOZOXjDbGL7c5zoWmy9u
26
- Fn5vEVdm/93J+84D/IMaaof3BwX/NNEYH01CeZEIGMfc5AFFha7dabzP/uiPpb/c
27
- GSvomC9IzyN37+eWwOS16cC+5XnBT6KRCaXYg2Fh6WpTgde67OVgXr4Q58HXlaZ+
28
- /2BB3wq9lZ4JskvlpYpYnlPAUyiyc6R2Mjts1pURz5nkW4SuS7Kd1KCOOyr1McDH
29
- VP12sTSjJclmI17BjDGQpAF0n9v5ExhJxWpeOjeBUPQsOin3ypEM1KkckLmOKvH6
30
- zyKMYVRO0z/58g==
31
- -----END CERTIFICATE-----
15
+ cert_chain: []
32
16
 
33
- date: 2010-03-30 00:00:00 -07:00
17
+ date: 2010-04-13 00:00:00 -07:00
34
18
  default_executable:
35
19
  dependencies:
36
20
  - !ruby/object:Gem::Dependency
37
21
  name: thrift_client
38
- type: :runtime
39
- version_requirement:
40
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
41
24
  requirements:
42
25
  - - ">="
43
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 4
30
+ - 0
44
31
  version: 0.4.0
45
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
46
34
  - !ruby/object:Gem::Dependency
47
35
  name: json
48
- type: :runtime
49
- version_requirement:
50
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
51
38
  requirements:
52
39
  - - ">="
53
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
54
43
  version: "0"
55
- version:
44
+ type: :runtime
45
+ version_requirements: *id002
56
46
  - !ruby/object:Gem::Dependency
57
47
  name: rake
58
- type: :runtime
59
- version_requirement:
60
- version_requirements: !ruby/object:Gem::Requirement
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
61
50
  requirements:
62
51
  - - ">="
63
52
  - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
64
55
  version: "0"
65
- version:
56
+ type: :runtime
57
+ version_requirements: *id003
66
58
  - !ruby/object:Gem::Dependency
67
59
  name: simple_uuid
68
- type: :runtime
69
- version_requirement:
70
- version_requirements: !ruby/object:Gem::Requirement
60
+ prerelease: false
61
+ requirement: &id004 !ruby/object:Gem::Requirement
71
62
  requirements:
72
63
  - - ">="
73
64
  - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
67
+ - 1
68
+ - 0
74
69
  version: 0.1.0
75
- version:
70
+ type: :runtime
71
+ version_requirements: *id004
76
72
  description: A Ruby client for the Cassandra distributed database.
77
73
  email: ""
78
74
  executables:
@@ -148,18 +144,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
144
  requirements:
149
145
  - - ">="
150
146
  - !ruby/object:Gem::Version
147
+ segments:
148
+ - 0
151
149
  version: "0"
152
- version:
153
150
  required_rubygems_version: !ruby/object:Gem::Requirement
154
151
  requirements:
155
152
  - - ">="
156
153
  - !ruby/object:Gem::Version
154
+ segments:
155
+ - 0
156
+ - 8
157
157
  version: "0.8"
158
- version:
159
158
  requirements: []
160
159
 
161
160
  rubyforge_project: fauna
162
- rubygems_version: 1.3.5
161
+ rubygems_version: 1.3.6
163
162
  signing_key:
164
163
  specification_version: 3
165
164
  summary: A Ruby client for the Cassandra distributed database.
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
Binary file