cassandra 0.5.6.2 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ v0.6. Use thrift_client gem.
3
+
2
4
  v0.5.6.2. Release process was busted.
3
5
 
4
6
  v0.5.6. Real multiget.
data/Manifest CHANGED
@@ -17,7 +17,6 @@ lib/cassandra/debug.rb
17
17
  lib/cassandra/long.rb
18
18
  lib/cassandra/ordered_hash.rb
19
19
  lib/cassandra/protocol.rb
20
- lib/cassandra/safe_client.rb
21
20
  lib/cassandra/time.rb
22
21
  lib/cassandra/uuid.rb
23
22
  test/cassandra_test.rb
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ unless ENV['FROM_BIN_CASSANDRA_HELPER']
8
8
  p.project = "fauna"
9
9
  p.summary = "A Ruby client for the Cassandra distributed database."
10
10
  p.rubygems_version = ">= 0.8"
11
- p.dependencies = ['thrift', 'rake']
11
+ p.dependencies = ['thrift_client', 'rake']
12
12
  p.ignore_pattern = /^(data|vendor\/cassandra|cassandra|vendor\/thrift)/
13
13
  p.rdoc_pattern = /^(lib|bin|tasks|ext)|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
14
14
  p.url = "http://blog.evanweaver.com/files/doc/fauna/cassandra/"
@@ -16,16 +16,16 @@ unless ENV['FROM_BIN_CASSANDRA_HELPER']
16
16
  end
17
17
  end
18
18
 
19
- REVISION = "33ac4dddb02c4b99dda34eefe842b2fcf4e81c6b"
19
+ REVISION = "c1fa17c0e359fa032bdb2d6b5f63120359ff881f"
20
20
 
21
- PATCHES = [
22
- "http://issues.apache.org/jira/secure/attachment/12418212/CASSANDRA-336-code.diff",
23
- "http://issues.apache.org/jira/secure/attachment/12418213/CASSANDRA-336-thrift.diff"]
21
+ PATCHES = []
24
22
 
25
23
  CASSANDRA_HOME = "#{ENV['HOME']}/cassandra/server"
26
24
 
27
25
  CASSANDRA_TEST = "#{ENV['HOME']}/cassandra/test"
28
26
 
27
+ GIT_REPO = "git://github.com/ryanking/cassandra.git"
28
+
29
29
  directory CASSANDRA_TEST
30
30
 
31
31
  desc "Start Cassandra"
@@ -63,42 +63,36 @@ task :git do
63
63
  end
64
64
 
65
65
  desc "Checkout Cassandra from git"
66
- task :checkout_cassandra => [:java, :git] do
66
+ task :clone_cassandra => [:java, :git] do
67
67
  # Like a git submodule, but all in one more obvious place
68
68
  unless File.exist?(CASSANDRA_HOME)
69
69
  puts "Checking Cassandra out from git"
70
- cmd = "git clone git://git.apache.org/cassandra.git #{CASSANDRA_HOME}"
70
+ cmd = "git clone #{GIT_REPO} #{CASSANDRA_HOME}"
71
71
  if !system(cmd)
72
72
  put "Checkout failed. Try:\n #{cmd}"
73
73
  exit(1)
74
74
  end
75
- end
75
+ end
76
76
  end
77
77
 
78
- desc "Apply patches to Cassandra checkout; use RESET=1 to force"
79
- task :patch_cassandra => [:checkout_cassandra] do
80
- # Verify checkout revision and patchset
81
- Dir.chdir(CASSANDRA_HOME) do
82
- current_checkout = `git show HEAD~#{PATCHES.size} | head -n1`
78
+ desc "Check out the right revision"
79
+ task :checkout_cassandra => [:clone_cassandra] do
80
+ Dir.chdir(CASSANDRA_HOME) do
81
+ current_checkout = `git log | head -n1`
83
82
  if !current_checkout.include?(REVISION)
84
- puts "Updating Cassandra and applying patches"
83
+ puts "Updating Cassandra."
85
84
  system("rm -rf #{CASSANDRA_TEST}/data")
86
85
  system("ant clean && git fetch && git reset #{REVISION} --hard")
87
- # Delete untracked files, so that the patchs can apply again
86
+ # Delete untracked files
88
87
  Array(`git status`[/Untracked files:(.*)$/m, 1].to_s.split("\n")[3..-1]).each do |file|
89
88
  File.unlink(file.sub(/^.\s+/, "")) rescue nil
90
89
  end
91
- # Patch, with a handy commit for each one
92
- PATCHES.each do |url|
93
- raise "#{url} failed" unless system("curl #{url} | patch -p1")
94
- system("git commit -a -m 'Applied patch: #{url.inspect}'")
95
- end
96
90
  end
97
91
  end
98
92
  end
99
93
 
100
94
  desc "Rebuild Cassandra"
101
- task :build_cassandra => [:patch_cassandra] do
95
+ task :build_cassandra => [:checkout_cassandra] do
102
96
  unless File.exist?("#{CASSANDRA_HOME}/build")
103
97
  puts "Building Cassandra"
104
98
  cmd = "cd #{CASSANDRA_HOME} && ant"
data/cassandra.gemspec CHANGED
@@ -2,23 +2,23 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{cassandra}
5
- s.version = "0.5.6.2"
5
+ s.version = "0.6"
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"]
9
9
  s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
10
- s.date = %q{2009-09-01}
10
+ s.date = %q{2009-11-18}
11
11
  s.default_executable = %q{cassandra_helper}
12
12
  s.description = %q{A Ruby client for the Cassandra distributed database.}
13
13
  s.email = %q{}
14
14
  s.executables = ["cassandra_helper"]
15
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/cassandra_helper", "lib/cassandra.rb", "lib/cassandra/array.rb", "lib/cassandra/cassandra.rb", "lib/cassandra/columns.rb", "lib/cassandra/comparable.rb", "lib/cassandra/constants.rb", "lib/cassandra/debug.rb", "lib/cassandra/long.rb", "lib/cassandra/ordered_hash.rb", "lib/cassandra/protocol.rb", "lib/cassandra/safe_client.rb", "lib/cassandra/time.rb", "lib/cassandra/uuid.rb"]
16
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/cassandra_helper", "conf/cassandra.in.sh", "conf/log4j.properties", "conf/storage-conf.xml", "lib/cassandra.rb", "lib/cassandra/array.rb", "lib/cassandra/cassandra.rb", "lib/cassandra/columns.rb", "lib/cassandra/comparable.rb", "lib/cassandra/constants.rb", "lib/cassandra/debug.rb", "lib/cassandra/long.rb", "lib/cassandra/ordered_hash.rb", "lib/cassandra/protocol.rb", "lib/cassandra/safe_client.rb", "lib/cassandra/time.rb", "lib/cassandra/uuid.rb", "test/cassandra_test.rb", "test/comparable_types_test.rb", "test/test_helper.rb", "vendor/gen-rb/cassandra.rb", "vendor/gen-rb/cassandra_constants.rb", "vendor/gen-rb/cassandra_types.rb", "cassandra.gemspec"]
15
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/cassandra_helper", "lib/cassandra.rb", "lib/cassandra/array.rb", "lib/cassandra/cassandra.rb", "lib/cassandra/columns.rb", "lib/cassandra/comparable.rb", "lib/cassandra/constants.rb", "lib/cassandra/debug.rb", "lib/cassandra/long.rb", "lib/cassandra/ordered_hash.rb", "lib/cassandra/protocol.rb", "lib/cassandra/time.rb", "lib/cassandra/uuid.rb"]
16
+ s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/cassandra_helper", "conf/cassandra.in.sh", "conf/log4j.properties", "conf/storage-conf.xml", "lib/cassandra.rb", "lib/cassandra/array.rb", "lib/cassandra/cassandra.rb", "lib/cassandra/columns.rb", "lib/cassandra/comparable.rb", "lib/cassandra/constants.rb", "lib/cassandra/debug.rb", "lib/cassandra/long.rb", "lib/cassandra/ordered_hash.rb", "lib/cassandra/protocol.rb", "lib/cassandra/time.rb", "lib/cassandra/uuid.rb", "test/cassandra_test.rb", "test/comparable_types_test.rb", "test/test_helper.rb", "vendor/gen-rb/cassandra.rb", "vendor/gen-rb/cassandra_constants.rb", "vendor/gen-rb/cassandra_types.rb", "cassandra.gemspec"]
17
17
  s.homepage = %q{http://blog.evanweaver.com/files/doc/fauna/cassandra/}
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Cassandra", "--main", "README"]
19
19
  s.require_paths = ["lib"]
20
20
  s.rubyforge_project = %q{fauna}
21
- s.rubygems_version = %q{1.3.4}
21
+ s.rubygems_version = %q{1.3.5}
22
22
  s.signing_key = %q{/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-private_key.pem}
23
23
  s.summary = %q{A Ruby client for the Cassandra distributed database.}
24
24
  s.test_files = ["test/cassandra_test.rb", "test/comparable_types_test.rb", "test/test_helper.rb"]
@@ -28,14 +28,14 @@ Gem::Specification.new do |s|
28
28
  s.specification_version = 3
29
29
 
30
30
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
31
- s.add_runtime_dependency(%q<thrift>, [">= 0"])
31
+ s.add_runtime_dependency(%q<thrift_client>, [">= 0"])
32
32
  s.add_runtime_dependency(%q<rake>, [">= 0"])
33
33
  else
34
- s.add_dependency(%q<thrift>, [">= 0"])
34
+ s.add_dependency(%q<thrift_client>, [">= 0"])
35
35
  s.add_dependency(%q<rake>, [">= 0"])
36
36
  end
37
37
  else
38
- s.add_dependency(%q<thrift>, [">= 0"])
38
+ s.add_dependency(%q<thrift_client>, [">= 0"])
39
39
  s.add_dependency(%q<rake>, [">= 0"])
40
40
  end
41
41
  end
data/conf/cassandra.in.sh CHANGED
@@ -36,7 +36,7 @@ JVM_OPTS=" \
36
36
  -ea \
37
37
  -Xdebug \
38
38
  -Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n \
39
- -Xms128M \
39
+ -Xms512M \
40
40
  -Xmx1G \
41
41
  -XX:SurvivorRatio=8 \
42
42
  -XX:TargetSurvivorRatio=90 \
@@ -51,6 +51,17 @@
51
51
  <ColumnFamily CompareWith="LongType" Name="Blogs"/>
52
52
  <ColumnFamily CompareWith="LongType" Name="Comments"/>
53
53
  </Keyspace>
54
+ <Keyspace Name="CassandraObject">
55
+ <KeysCachedFraction>0.01</KeysCachedFraction>
56
+ <ColumnFamily CompareWith="UTF8Type" Name="Customers" />
57
+ <ColumnFamily CompareWith="UTF8Type" CompareSubcolumnsWith="TimeUUIDType" ColumnType="Super" Name="CustomerRelationships" />
58
+ <ColumnFamily CompareWith="UTF8Type" CompareSubcolumnsWith="TimeUUIDType" ColumnType="Super" Name="CustomersByLastName" />
59
+ <ColumnFamily CompareWith="UTF8Type" Name="Invoices" />
60
+ <ColumnFamily CompareWith="UTF8Type" CompareSubcolumnsWith="TimeUUIDType" ColumnType="Super" Name="InvoiceRelationships" />
61
+ <ColumnFamily CompareWith="UTF8Type" Name="InvoicesByNumber" />
62
+ <ColumnFamily CompareWith="UTF8Type" Name="Payments" />
63
+ <ColumnFamily CompareWith="UTF8Type" Name="Appointments" />
64
+ </Keyspace>
54
65
  </Keyspaces>
55
66
 
56
67
  <!-- Partitioner: any IPartitioner may be used, including your own
data/lib/cassandra.rb CHANGED
@@ -1,20 +1,17 @@
1
-
2
- require 'zlib'
3
1
  require 'rubygems'
4
- require 'thrift'
2
+ require 'thrift_client'
5
3
 
6
- HERE = File.expand_path(File.dirname(__FILE__))
4
+ here = File.expand_path(File.dirname(__FILE__))
7
5
 
8
- $LOAD_PATH << "#{HERE}/../vendor/gen-rb"
9
- require "#{HERE}/../vendor/gen-rb/cassandra"
6
+ $LOAD_PATH << "#{here}/../vendor/gen-rb"
7
+ require "#{here}/../vendor/gen-rb/cassandra"
10
8
 
11
- $LOAD_PATH << "#{HERE}"
9
+ $LOAD_PATH << "#{here}"
12
10
  require 'cassandra/array'
13
11
  require 'cassandra/time'
14
12
  require 'cassandra/comparable'
15
13
  require 'cassandra/uuid'
16
14
  require 'cassandra/long'
17
- require 'cassandra/safe_client'
18
15
  require 'cassandra/ordered_hash'
19
16
  require 'cassandra/columns'
20
17
  require 'cassandra/protocol'
@@ -52,39 +52,43 @@ class Cassandra
52
52
  :reversed => false,
53
53
  :consistency => Consistency::ONE
54
54
  }.freeze
55
+
56
+ THRIFT_DEFAULTS = {
57
+ :transport => Thrift::BufferedTransport
58
+ }.freeze
55
59
 
56
- attr_reader :keyspace, :host, :port, :serializer, :transport, :client, :schema
60
+ attr_reader :keyspace, :servers, :schema, :thrift_client_options
57
61
 
58
- # Instantiate a new Cassandra and open the connection.
59
- def initialize(keyspace, host = '127.0.0.1', port = 9160, buffer = true)
62
+ # Create a new Cassandra instance and open the connection.
63
+ def initialize(keyspace, servers = "127.0.0.1:9160", thrift_client_options = {})
60
64
  @is_super = {}
61
65
  @column_name_class = {}
62
66
  @sub_column_name_class = {}
67
+ @thrift_client_options = THRIFT_DEFAULTS.merge(thrift_client_options)
63
68
 
64
69
  @keyspace = keyspace
65
- @host = host
66
- @port = port
70
+ @servers = Array(servers)
71
+ end
67
72
 
68
- transport = Thrift::BufferedTransport.new(Thrift::Socket.new(@host, @port))
69
- transport.open
70
-
71
- @client = CassandraThrift::Cassandra::SafeClient.new(
72
- CassandraThrift::Cassandra::Client.new(Thrift::BinaryProtocol.new(transport)),
73
- transport,
74
- !buffer)
75
-
76
- keyspaces = @client.get_string_list_property("keyspaces")
77
- unless keyspaces.include?(@keyspace)
78
- raise AccessError, "Keyspace #{@keyspace.inspect} not found. Available: #{keyspaces.inspect}"
73
+
74
+ def client
75
+ @client ||= begin
76
+ client = ThriftClient.new(CassandraThrift::Cassandra::Client, @servers, @thrift_client_options)
77
+ unless client.get_string_list_property("keyspaces").include?(@keyspace)
78
+ raise AccessError, "Keyspace #{@keyspace.inspect} not found. Available: #{keyspaces.inspect}"
79
+ end
80
+ client
79
81
  end
82
+ end
80
83
 
81
- @schema = @client.describe_keyspace(@keyspace)
84
+ def keyspaces
85
+ @keyspaces ||= client.get_string_list_property("keyspaces")
82
86
  end
83
87
 
84
88
  def inspect
85
89
  "#<Cassandra:#{object_id}, @keyspace=#{keyspace.inspect}, @schema={#{
86
- schema.map {|name, hash| ":#{name} => #{hash['type'].inspect}"}.join(', ')
87
- }}, @host=#{host.inspect}, @port=#{port}>"
90
+ schema(false).map {|name, hash| ":#{name} => #{hash['type'].inspect}"}.join(', ')
91
+ }}, @servers=#{servers.inspect}>"
88
92
  end
89
93
 
90
94
  ### Write
@@ -93,17 +97,13 @@ class Cassandra
93
97
  # a nested hash for a super column family. Supports the <tt>:consistency</tt>
94
98
  # and <tt>:timestamp</tt> options.
95
99
  def insert(column_family, key, hash, options = {})
96
- column_family, _, _, options =
97
- validate_params(column_family, key, [options], WRITE_DEFAULTS)
100
+ column_family, _, _, options = validate_params(column_family, key, [options], WRITE_DEFAULTS)
98
101
 
99
- args = [column_family, hash, options[:timestamp] || Time.stamp]
100
- columns = is_super(column_family) ? hash_to_super_columns(*args) : hash_to_columns(*args)
101
- mutation = CassandraThrift::BatchMutation.new(
102
- :key => key,
103
- :cfmap => {column_family => columns},
104
- :column_paths => [])
102
+ timestamp = options[:timestamp] || Time.stamp
103
+ cfmap = hash_to_cfmap(column_family, hash, timestamp)
104
+ mutation = [:insert, [key, cfmap, options[:consistency]]]
105
105
 
106
- @batch ? @batch << mutation : _mutate([mutation], options[:consistency])
106
+ @batch ? @batch << mutation : _insert(*mutation[1])
107
107
  end
108
108
 
109
109
  ## Delete
@@ -112,17 +112,15 @@ class Cassandra
112
112
  # path you request. Supports the <tt>:consistency</tt> and <tt>:timestamp</tt>
113
113
  # options.
114
114
  def remove(column_family, key, *columns_and_options)
115
- column_family, column, sub_column, options =
116
- validate_params(column_family, key, columns_and_options, WRITE_DEFAULTS)
115
+ column_family, column, sub_column, options = validate_params(column_family, key, columns_and_options, WRITE_DEFAULTS)
117
116
 
118
- args = {:column_family => column_family, :timestamp => options[:timestamp] || Time.stamp}
117
+ args = {:column_family => column_family}
119
118
  columns = is_super(column_family) ? {:super_column => column, :column => sub_column} : {:column => column}
120
- mutation = CassandraThrift::BatchMutation.new(
121
- :key => key,
122
- :cfmap => {},
123
- :column_paths => [CassandraThrift::ColumnPath.new(args.merge(columns))])
124
-
125
- @batch ? @batch << mutation : _mutate([mutation], options[:consistency])
119
+ column_path = CassandraThrift::ColumnPath.new(args.merge(columns))
120
+
121
+ mutation = [:remove, [key, column_path, options[:timestamp] || Time.stamp, options[:consistency]]]
122
+
123
+ @batch ? @batch << mutation : _remove(*mutation[1])
126
124
  end
127
125
 
128
126
  # Remove all rows in the column family you request. Supports options
@@ -138,7 +136,7 @@ class Cassandra
138
136
  # FIXME May not currently delete all records without multiple calls. Waiting
139
137
  # for ranged remove support in Cassandra.
140
138
  def clear_keyspace!(options = {})
141
- @schema.keys.each { |column_family| clear_column_family!(column_family, options) }
139
+ schema.keys.each { |column_family| clear_column_family!(column_family, options) }
142
140
  end
143
141
 
144
142
  ### Read
@@ -227,12 +225,21 @@ class Cassandra
227
225
  # the individual commands.
228
226
  def batch(options = {})
229
227
  _, _, _, options =
230
- validate_params(@schema.keys.first, "", [options], WRITE_DEFAULTS)
228
+ validate_params(schema.keys.first, "", [options], WRITE_DEFAULTS)
231
229
 
232
230
  @batch = []
233
231
  yield
234
232
  compact_mutations!
235
- _mutate(@batch, options[:consistency])
233
+
234
+ @batch.each do |mutation|
235
+ case mutation.first
236
+ when :insert
237
+ _insert(*mutation[1])
238
+ when :remove
239
+ _remove(*mutation[1])
240
+ end
241
+ end
242
+ ensure
236
243
  @batch = nil
237
244
  end
238
245
 
@@ -243,9 +250,8 @@ class Cassandra
243
250
  def validate_params(column_family, keys, args, options)
244
251
  options = options.dup
245
252
  column_family = column_family.to_s
246
-
247
253
  # Keys
248
- Array(keys).each do |key|
254
+ [keys].flatten.each do |key|
249
255
  raise ArgumentError, "Key #{key.inspect} must be a String for #{calling_method}" unless key.is_a?(String)
250
256
  end
251
257
 
@@ -282,25 +288,14 @@ class Cassandra
282
288
 
283
289
  # Roll up queued mutations, to improve atomicity.
284
290
  def compact_mutations!
285
- mutations = {}
286
-
287
- # Nested hash merge
288
- @batch.each do |m|
289
- if mutation = mutations[m.key]
290
- # Inserts
291
- if columns = mutation.cfmap[m.cfmap.keys.first]
292
- columns.concat(m.cfmap.values.first)
293
- else
294
- mutation.cfmap.merge!(m.cfmap)
295
- end
296
- # Deletes
297
- mutation.column_paths.concat(m.column_paths)
298
- else
299
- mutations[m.key] = m
300
- end
301
- end
291
+ #TODO re-do this rollup
292
+ end
302
293
 
303
- # FIXME Return atomic thrift thingy
304
- @batch = mutations.values
294
+ def schema(load=true)
295
+ if !load && !@schema
296
+ []
297
+ else
298
+ @schema ||= client.describe_keyspace(@keyspace)
299
+ end
305
300
  end
306
301
  end
@@ -3,19 +3,19 @@ class Cassandra
3
3
  # A bunch of crap, mostly related to introspecting on column types
4
4
  module Columns #:nodoc:
5
5
  private
6
-
6
+
7
7
  def is_super(column_family)
8
8
  @is_super[column_family] ||= column_family_property(column_family, 'Type') == "Super"
9
9
  end
10
-
10
+
11
11
  def column_name_class(column_family)
12
12
  @column_name_class[column_family] ||= column_name_class_for_key(column_family, "CompareWith")
13
13
  end
14
-
14
+
15
15
  def sub_column_name_class(column_family)
16
16
  @sub_column_name_class[column_family] ||= column_name_class_for_key(column_family, "CompareSubcolumnsWith")
17
17
  end
18
-
18
+
19
19
  def column_name_class_for_key(column_family, comparator_key)
20
20
  property = column_family_property(column_family, comparator_key)
21
21
  property =~ /.*\.(.*?)$/
@@ -28,17 +28,17 @@ class Cassandra
28
28
  end
29
29
 
30
30
  def column_family_property(column_family, key)
31
- @schema[column_family][key]
31
+ schema[column_family][key]
32
32
  rescue NoMethodError
33
33
  raise AccessError, "Invalid column family \"#{column_family}\""
34
34
  end
35
-
35
+
36
36
  def multi_column_to_hash!(hash)
37
37
  hash.each do |key, column_or_supercolumn|
38
38
  hash[key] = (column_or_supercolumn.column.value if column_or_supercolumn.column)
39
39
  end
40
40
  end
41
-
41
+
42
42
  def multi_columns_to_hash!(column_family, hash)
43
43
  hash.each do |key, columns|
44
44
  hash[key] = columns_to_hash(column_family, columns)
@@ -50,7 +50,7 @@ class Cassandra
50
50
  hash[key] = sub_columns_to_hash(column_family, sub_columns)
51
51
  end
52
52
  end
53
-
53
+
54
54
  def columns_to_hash(column_family, columns)
55
55
  columns_to_hash_for_classes(columns, column_name_class(column_family), sub_column_name_class(column_family))
56
56
  end
@@ -58,7 +58,7 @@ class Cassandra
58
58
  def sub_columns_to_hash(column_family, columns)
59
59
  columns_to_hash_for_classes(columns, sub_column_name_class(column_family))
60
60
  end
61
-
61
+
62
62
  def columns_to_hash_for_classes(columns, column_name_class, sub_column_name_class = nil)
63
63
  hash = OrderedHash.new
64
64
  Array(columns).each do |c|
@@ -72,30 +72,36 @@ class Cassandra
72
72
  end
73
73
  hash
74
74
  end
75
-
76
- def hash_to_columns(column_family, hash, timestamp)
77
- hash.map do |column, value|
78
- CassandraThrift::ColumnOrSuperColumn.new(:column =>
79
- CassandraThrift::Column.new(
80
- :name => column_name_class(column_family).new(column).to_s,
81
- :value => value,
82
- :timestamp => timestamp))
83
- end
84
- end
85
-
86
- def hash_to_super_columns(column_family, hash, timestamp)
87
- hash.map do |column, sub_hash|
88
- sub_columns = sub_hash.map do |sub_column, value|
89
- CassandraThrift::Column.new(
90
- :name => sub_column_name_class(column_family).new(sub_column).to_s,
91
- :value => value,
92
- :timestamp => timestamp)
93
- end
94
- CassandraThrift::ColumnOrSuperColumn.new(:super_column =>
95
- CassandraThrift::SuperColumn.new(
96
- :name => column_name_class(column_family).new(column).to_s,
97
- :columns => sub_columns))
75
+
76
+ def hash_to_cfmap(column_family, hash, timestamp)
77
+ h = Hash.new
78
+ if is_super(column_family)
79
+ h[column_family] = hash.collect do |super_column_name, sub_columns|
80
+ CassandraThrift::ColumnOrSuperColumn.new(
81
+ :super_column => CassandraThrift::SuperColumn.new(
82
+ :name => column_name_class(column_family).new(super_column_name).to_s,
83
+ :columns => sub_columns.collect { |sub_column_name, sub_column_value|
84
+ CassandraThrift::Column.new(
85
+ :name => sub_column_name_class(column_family).new(sub_column_name).to_s,
86
+ :value => sub_column_value,
87
+ :timestamp => timestamp
88
+ )
89
+ }
90
+ )
91
+ )
92
+ end
93
+ else
94
+ h[column_family] = hash.collect do |column_name, value|
95
+ CassandraThrift::ColumnOrSuperColumn.new(
96
+ :column => CassandraThrift::Column.new(
97
+ :name => column_name_class(column_family).new(column_name).to_s,
98
+ :value => value,
99
+ :timestamp => timestamp
100
+ )
101
+ )
102
+ end
98
103
  end
99
- end
104
+ h
105
+ end
100
106
  end
101
107
  end
@@ -4,8 +4,12 @@ class Cassandra
4
4
  module Protocol #:nodoc:
5
5
  private
6
6
 
7
- def _mutate(mutation, consistency)
8
- @client.batch_mutate(@keyspace, mutation, consistency)
7
+ def _insert(key, cfmap, consistency_level)
8
+ @client.batch_insert(@keyspace, key, cfmap, consistency_level)
9
+ end
10
+
11
+ def _remove(key, column_path, timestamp, consistency_level)
12
+ @client.remove(@keyspace, key, column_path, timestamp, consistency_level)
9
13
  end
10
14
 
11
15
  def _count_columns(column_family, key, super_column, consistency)
@@ -4,13 +4,13 @@ class CassandraTest < Test::Unit::TestCase
4
4
  include Cassandra::Constants
5
5
 
6
6
  def setup
7
- @twitter = Cassandra.new('Twitter', '127.0.0.1')
7
+ @twitter = Cassandra.new('Twitter', "127.0.0.1:9160", :retries => 2)
8
8
  @twitter.clear_keyspace!
9
9
 
10
- @blogs = Cassandra.new('Multiblog', '127.0.0.1')
10
+ @blogs = Cassandra.new('Multiblog')
11
11
  @blogs.clear_keyspace!
12
12
 
13
- @blogs_long = Cassandra.new('MultiblogLong', '127.0.0.1')
13
+ @blogs_long = Cassandra.new('MultiblogLong')
14
14
  @blogs_long.clear_keyspace!
15
15
 
16
16
  @uuids = (0..6).map {|i| UUID.new(Time.at(2**(24+i))) }
@@ -26,7 +26,7 @@ class CassandraTest < Test::Unit::TestCase
26
26
 
27
27
  def test_connection_reopens
28
28
  assert_raises(Thrift::ProtocolException) do
29
- @twitter.send("_mutate", [], -5)
29
+ @twitter.send("_insert", [], -5, '')
30
30
  end
31
31
  assert_nothing_raised do
32
32
  @twitter.insert(:Statuses, key, {'body' => 'v'})
@@ -318,6 +318,12 @@ class CassandraTest < Test::Unit::TestCase
318
318
  assert_equal({}, @twitter.get(:Users, key + '1')) # Removed
319
319
  end
320
320
 
321
+ def test_complain_about_nil_key
322
+ assert_raises(ArgumentError) do
323
+ @twitter.insert(:Statuses, nil, {'text' => 'crap'})
324
+ end
325
+ end
326
+
321
327
  private
322
328
 
323
329
  def key
data/test/test_helper.rb CHANGED
@@ -4,7 +4,7 @@ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/cassandra"
4
4
  begin; require 'ruby-debug'; rescue LoadError; end
5
5
 
6
6
  begin
7
- @test_client = Cassandra.new('Twitter', '127.0.0.1')
7
+ @test_client = Cassandra.new('Twitter')
8
8
  rescue Thrift::TransportException => e
9
9
  #FIXME Make server automatically start if not running
10
10
  if e.message =~ /Could not connect/
@@ -26,6 +26,7 @@ require 'cassandra_types'
26
26
  return result.success unless result.success.nil?
27
27
  raise result.ire unless result.ire.nil?
28
28
  raise result.nfe unless result.nfe.nil?
29
+ raise result.ue unless result.ue.nil?
29
30
  raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get failed: unknown result')
30
31
  end
31
32
 
@@ -43,6 +44,7 @@ require 'cassandra_types'
43
44
  return result.success unless result.success.nil?
44
45
  raise result.ire unless result.ire.nil?
45
46
  raise result.nfe unless result.nfe.nil?
47
+ raise result.ue unless result.ue.nil?
46
48
  raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_slice failed: unknown result')
47
49
  end
48
50
 
@@ -59,6 +61,7 @@ require 'cassandra_types'
59
61
  result = receive_message(Multiget_result)
60
62
  return result.success unless result.success.nil?
61
63
  raise result.ire unless result.ire.nil?
64
+ raise result.ue unless result.ue.nil?
62
65
  raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'multiget failed: unknown result')
63
66
  end
64
67
 
@@ -75,6 +78,7 @@ require 'cassandra_types'
75
78
  result = receive_message(Multiget_slice_result)
76
79
  return result.success unless result.success.nil?
77
80
  raise result.ire unless result.ire.nil?
81
+ raise result.ue unless result.ue.nil?
78
82
  raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'multiget_slice failed: unknown result')
79
83
  end
80
84
 
@@ -91,6 +95,7 @@ require 'cassandra_types'
91
95
  result = receive_message(Get_count_result)
92
96
  return result.success unless result.success.nil?
93
97
  raise result.ire unless result.ire.nil?
98
+ raise result.ue unless result.ue.nil?
94
99
  raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_count failed: unknown result')
95
100
  end
96
101
 
@@ -107,6 +112,7 @@ require 'cassandra_types'
107
112
  result = receive_message(Get_key_range_result)
108
113
  return result.success unless result.success.nil?
109
114
  raise result.ire unless result.ire.nil?
115
+ raise result.ue unless result.ue.nil?
110
116
  raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_key_range failed: unknown result')
111
117
  end
112
118
 
@@ -126,17 +132,17 @@ require 'cassandra_types'
126
132
  return
127
133
  end
128
134
 
129
- def batch_mutate(keyspace, batch_mutations, consistency_level)
130
- send_batch_mutate(keyspace, batch_mutations, consistency_level)
131
- recv_batch_mutate()
135
+ def batch_insert(keyspace, key, cfmap, consistency_level)
136
+ send_batch_insert(keyspace, key, cfmap, consistency_level)
137
+ recv_batch_insert()
132
138
  end
133
139
 
134
- def send_batch_mutate(keyspace, batch_mutations, consistency_level)
135
- send_message('batch_mutate', Batch_mutate_args, :keyspace => keyspace, :batch_mutations => batch_mutations, :consistency_level => consistency_level)
140
+ def send_batch_insert(keyspace, key, cfmap, consistency_level)
141
+ send_message('batch_insert', Batch_insert_args, :keyspace => keyspace, :key => key, :cfmap => cfmap, :consistency_level => consistency_level)
136
142
  end
137
143
 
138
- def recv_batch_mutate()
139
- result = receive_message(Batch_mutate_result)
144
+ def recv_batch_insert()
145
+ result = receive_message(Batch_insert_result)
140
146
  raise result.ire unless result.ire.nil?
141
147
  raise result.ue unless result.ue.nil?
142
148
  return
@@ -218,6 +224,8 @@ require 'cassandra_types'
218
224
  result.ire = ire
219
225
  rescue CassandraThrift::NotFoundException => nfe
220
226
  result.nfe = nfe
227
+ rescue CassandraThrift::UnavailableException => ue
228
+ result.ue = ue
221
229
  end
222
230
  write_result(result, oprot, 'get', seqid)
223
231
  end
@@ -231,6 +239,8 @@ require 'cassandra_types'
231
239
  result.ire = ire
232
240
  rescue CassandraThrift::NotFoundException => nfe
233
241
  result.nfe = nfe
242
+ rescue CassandraThrift::UnavailableException => ue
243
+ result.ue = ue
234
244
  end
235
245
  write_result(result, oprot, 'get_slice', seqid)
236
246
  end
@@ -242,6 +252,8 @@ require 'cassandra_types'
242
252
  result.success = @handler.multiget(args.keyspace, args.keys, args.column_path, args.consistency_level)
243
253
  rescue CassandraThrift::InvalidRequestException => ire
244
254
  result.ire = ire
255
+ rescue CassandraThrift::UnavailableException => ue
256
+ result.ue = ue
245
257
  end
246
258
  write_result(result, oprot, 'multiget', seqid)
247
259
  end
@@ -253,6 +265,8 @@ require 'cassandra_types'
253
265
  result.success = @handler.multiget_slice(args.keyspace, args.keys, args.column_parent, args.predicate, args.consistency_level)
254
266
  rescue CassandraThrift::InvalidRequestException => ire
255
267
  result.ire = ire
268
+ rescue CassandraThrift::UnavailableException => ue
269
+ result.ue = ue
256
270
  end
257
271
  write_result(result, oprot, 'multiget_slice', seqid)
258
272
  end
@@ -264,6 +278,8 @@ require 'cassandra_types'
264
278
  result.success = @handler.get_count(args.keyspace, args.key, args.column_parent, args.consistency_level)
265
279
  rescue CassandraThrift::InvalidRequestException => ire
266
280
  result.ire = ire
281
+ rescue CassandraThrift::UnavailableException => ue
282
+ result.ue = ue
267
283
  end
268
284
  write_result(result, oprot, 'get_count', seqid)
269
285
  end
@@ -275,6 +291,8 @@ require 'cassandra_types'
275
291
  result.success = @handler.get_key_range(args.keyspace, args.column_family, args.start, args.finish, args.count, args.consistency_level)
276
292
  rescue CassandraThrift::InvalidRequestException => ire
277
293
  result.ire = ire
294
+ rescue CassandraThrift::UnavailableException => ue
295
+ result.ue = ue
278
296
  end
279
297
  write_result(result, oprot, 'get_key_range', seqid)
280
298
  end
@@ -292,17 +310,17 @@ require 'cassandra_types'
292
310
  write_result(result, oprot, 'insert', seqid)
293
311
  end
294
312
 
295
- def process_batch_mutate(seqid, iprot, oprot)
296
- args = read_args(iprot, Batch_mutate_args)
297
- result = Batch_mutate_result.new()
313
+ def process_batch_insert(seqid, iprot, oprot)
314
+ args = read_args(iprot, Batch_insert_args)
315
+ result = Batch_insert_result.new()
298
316
  begin
299
- @handler.batch_mutate(args.keyspace, args.batch_mutations, args.consistency_level)
317
+ @handler.batch_insert(args.keyspace, args.key, args.cfmap, args.consistency_level)
300
318
  rescue CassandraThrift::InvalidRequestException => ire
301
319
  result.ire = ire
302
320
  rescue CassandraThrift::UnavailableException => ue
303
321
  result.ue = ue
304
322
  end
305
- write_result(result, oprot, 'batch_mutate', seqid)
323
+ write_result(result, oprot, 'batch_insert', seqid)
306
324
  end
307
325
 
308
326
  def process_remove(seqid, iprot, oprot)
@@ -377,12 +395,14 @@ require 'cassandra_types'
377
395
  SUCCESS = 0
378
396
  IRE = 1
379
397
  NFE = 2
398
+ UE = 3
380
399
 
381
- ::Thrift::Struct.field_accessor self, :success, :ire, :nfe
400
+ ::Thrift::Struct.field_accessor self, :success, :ire, :nfe, :ue
382
401
  FIELDS = {
383
402
  SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => CassandraThrift::ColumnOrSuperColumn},
384
403
  IRE => {:type => ::Thrift::Types::STRUCT, :name => 'ire', :class => CassandraThrift::InvalidRequestException},
385
- NFE => {:type => ::Thrift::Types::STRUCT, :name => 'nfe', :class => CassandraThrift::NotFoundException}
404
+ NFE => {:type => ::Thrift::Types::STRUCT, :name => 'nfe', :class => CassandraThrift::NotFoundException},
405
+ UE => {:type => ::Thrift::Types::STRUCT, :name => 'ue', :class => CassandraThrift::UnavailableException}
386
406
  }
387
407
 
388
408
  def struct_fields; FIELDS; end
@@ -424,12 +444,14 @@ require 'cassandra_types'
424
444
  SUCCESS = 0
425
445
  IRE = 1
426
446
  NFE = 2
447
+ UE = 3
427
448
 
428
- ::Thrift::Struct.field_accessor self, :success, :ire, :nfe
449
+ ::Thrift::Struct.field_accessor self, :success, :ire, :nfe, :ue
429
450
  FIELDS = {
430
451
  SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => CassandraThrift::ColumnOrSuperColumn}},
431
452
  IRE => {:type => ::Thrift::Types::STRUCT, :name => 'ire', :class => CassandraThrift::InvalidRequestException},
432
- NFE => {:type => ::Thrift::Types::STRUCT, :name => 'nfe', :class => CassandraThrift::NotFoundException}
453
+ NFE => {:type => ::Thrift::Types::STRUCT, :name => 'nfe', :class => CassandraThrift::NotFoundException},
454
+ UE => {:type => ::Thrift::Types::STRUCT, :name => 'ue', :class => CassandraThrift::UnavailableException}
433
455
  }
434
456
 
435
457
  def struct_fields; FIELDS; end
@@ -468,11 +490,13 @@ require 'cassandra_types'
468
490
  include ::Thrift::Struct
469
491
  SUCCESS = 0
470
492
  IRE = 1
493
+ UE = 2
471
494
 
472
- ::Thrift::Struct.field_accessor self, :success, :ire
495
+ ::Thrift::Struct.field_accessor self, :success, :ire, :ue
473
496
  FIELDS = {
474
497
  SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRUCT, :class => CassandraThrift::ColumnOrSuperColumn}},
475
- IRE => {:type => ::Thrift::Types::STRUCT, :name => 'ire', :class => CassandraThrift::InvalidRequestException}
498
+ IRE => {:type => ::Thrift::Types::STRUCT, :name => 'ire', :class => CassandraThrift::InvalidRequestException},
499
+ UE => {:type => ::Thrift::Types::STRUCT, :name => 'ue', :class => CassandraThrift::UnavailableException}
476
500
  }
477
501
 
478
502
  def struct_fields; FIELDS; end
@@ -513,11 +537,13 @@ require 'cassandra_types'
513
537
  include ::Thrift::Struct
514
538
  SUCCESS = 0
515
539
  IRE = 1
540
+ UE = 2
516
541
 
517
- ::Thrift::Struct.field_accessor self, :success, :ire
542
+ ::Thrift::Struct.field_accessor self, :success, :ire, :ue
518
543
  FIELDS = {
519
544
  SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => CassandraThrift::ColumnOrSuperColumn}}},
520
- IRE => {:type => ::Thrift::Types::STRUCT, :name => 'ire', :class => CassandraThrift::InvalidRequestException}
545
+ IRE => {:type => ::Thrift::Types::STRUCT, :name => 'ire', :class => CassandraThrift::InvalidRequestException},
546
+ UE => {:type => ::Thrift::Types::STRUCT, :name => 'ue', :class => CassandraThrift::UnavailableException}
521
547
  }
522
548
 
523
549
  def struct_fields; FIELDS; end
@@ -532,7 +558,7 @@ require 'cassandra_types'
532
558
  KEYSPACE = 1
533
559
  KEY = 2
534
560
  COLUMN_PARENT = 3
535
- CONSISTENCY_LEVEL = 5
561
+ CONSISTENCY_LEVEL = 4
536
562
 
537
563
  ::Thrift::Struct.field_accessor self, :keyspace, :key, :column_parent, :consistency_level
538
564
  FIELDS = {
@@ -556,11 +582,13 @@ require 'cassandra_types'
556
582
  include ::Thrift::Struct
557
583
  SUCCESS = 0
558
584
  IRE = 1
585
+ UE = 2
559
586
 
560
- ::Thrift::Struct.field_accessor self, :success, :ire
587
+ ::Thrift::Struct.field_accessor self, :success, :ire, :ue
561
588
  FIELDS = {
562
589
  SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'},
563
- IRE => {:type => ::Thrift::Types::STRUCT, :name => 'ire', :class => CassandraThrift::InvalidRequestException}
590
+ IRE => {:type => ::Thrift::Types::STRUCT, :name => 'ire', :class => CassandraThrift::InvalidRequestException},
591
+ UE => {:type => ::Thrift::Types::STRUCT, :name => 'ue', :class => CassandraThrift::UnavailableException}
564
592
  }
565
593
 
566
594
  def struct_fields; FIELDS; end
@@ -603,11 +631,13 @@ require 'cassandra_types'
603
631
  include ::Thrift::Struct
604
632
  SUCCESS = 0
605
633
  IRE = 1
634
+ UE = 2
606
635
 
607
- ::Thrift::Struct.field_accessor self, :success, :ire
636
+ ::Thrift::Struct.field_accessor self, :success, :ire, :ue
608
637
  FIELDS = {
609
638
  SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRING}},
610
- IRE => {:type => ::Thrift::Types::STRUCT, :name => 'ire', :class => CassandraThrift::InvalidRequestException}
639
+ IRE => {:type => ::Thrift::Types::STRUCT, :name => 'ire', :class => CassandraThrift::InvalidRequestException},
640
+ UE => {:type => ::Thrift::Types::STRUCT, :name => 'ue', :class => CassandraThrift::UnavailableException}
611
641
  }
612
642
 
613
643
  def struct_fields; FIELDS; end
@@ -664,16 +694,18 @@ require 'cassandra_types'
664
694
 
665
695
  end
666
696
 
667
- class Batch_mutate_args
697
+ class Batch_insert_args
668
698
  include ::Thrift::Struct
669
699
  KEYSPACE = 1
670
- BATCH_MUTATIONS = 2
671
- CONSISTENCY_LEVEL = 3
700
+ KEY = 2
701
+ CFMAP = 3
702
+ CONSISTENCY_LEVEL = 4
672
703
 
673
- ::Thrift::Struct.field_accessor self, :keyspace, :batch_mutations, :consistency_level
704
+ ::Thrift::Struct.field_accessor self, :keyspace, :key, :cfmap, :consistency_level
674
705
  FIELDS = {
675
706
  KEYSPACE => {:type => ::Thrift::Types::STRING, :name => 'keyspace'},
676
- BATCH_MUTATIONS => {:type => ::Thrift::Types::LIST, :name => 'batch_mutations', :element => {:type => ::Thrift::Types::STRUCT, :class => CassandraThrift::BatchMutation}},
707
+ KEY => {:type => ::Thrift::Types::STRING, :name => 'key'},
708
+ CFMAP => {:type => ::Thrift::Types::MAP, :name => 'cfmap', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => CassandraThrift::ColumnOrSuperColumn}}},
677
709
  CONSISTENCY_LEVEL => {:type => ::Thrift::Types::I32, :name => 'consistency_level', :default => 0, :enum_class => CassandraThrift::ConsistencyLevel}
678
710
  }
679
711
 
@@ -687,7 +719,7 @@ require 'cassandra_types'
687
719
 
688
720
  end
689
721
 
690
- class Batch_mutate_result
722
+ class Batch_insert_result
691
723
  include ::Thrift::Struct
692
724
  IRE = 1
693
725
  UE = 2
@@ -152,14 +152,12 @@ module CassandraThrift
152
152
  COLUMN_FAMILY = 3
153
153
  SUPER_COLUMN = 4
154
154
  COLUMN = 5
155
- TIMESTAMP = 6
156
155
 
157
- ::Thrift::Struct.field_accessor self, :column_family, :super_column, :column, :timestamp
156
+ ::Thrift::Struct.field_accessor self, :column_family, :super_column, :column
158
157
  FIELDS = {
159
158
  COLUMN_FAMILY => {:type => ::Thrift::Types::STRING, :name => 'column_family'},
160
159
  SUPER_COLUMN => {:type => ::Thrift::Types::STRING, :name => 'super_column', :optional => true},
161
- COLUMN => {:type => ::Thrift::Types::STRING, :name => 'column', :optional => true},
162
- TIMESTAMP => {:type => ::Thrift::Types::I64, :name => 'timestamp', :optional => true}
160
+ COLUMN => {:type => ::Thrift::Types::STRING, :name => 'column', :optional => true}
163
161
  }
164
162
 
165
163
  def struct_fields; FIELDS; end
@@ -214,25 +212,4 @@ module CassandraThrift
214
212
 
215
213
  end
216
214
 
217
- class BatchMutation
218
- include ::Thrift::Struct
219
- KEY = 1
220
- CFMAP = 2
221
- COLUMN_PATHS = 3
222
-
223
- ::Thrift::Struct.field_accessor self, :key, :cfmap, :column_paths
224
- FIELDS = {
225
- KEY => {:type => ::Thrift::Types::STRING, :name => 'key'},
226
- CFMAP => {:type => ::Thrift::Types::MAP, :name => 'cfmap', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => CassandraThrift::ColumnOrSuperColumn}}, :optional => true},
227
- COLUMN_PATHS => {:type => ::Thrift::Types::LIST, :name => 'column_paths', :element => {:type => ::Thrift::Types::STRUCT, :class => CassandraThrift::ColumnPath}, :optional => true}
228
- }
229
-
230
- def struct_fields; FIELDS; end
231
-
232
- def validate
233
- raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field key is unset!') unless @key
234
- end
235
-
236
- end
237
-
238
215
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassandra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6.2
4
+ version: "0.6"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Weaver
@@ -30,11 +30,11 @@ cert_chain:
30
30
  yZ0=
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2009-09-01 00:00:00 -07:00
33
+ date: 2009-11-18 00:00:00 -08:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
- name: thrift
37
+ name: thrift_client
38
38
  type: :runtime
39
39
  version_requirement:
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,6 @@ extra_rdoc_files:
74
74
  - lib/cassandra/long.rb
75
75
  - lib/cassandra/ordered_hash.rb
76
76
  - lib/cassandra/protocol.rb
77
- - lib/cassandra/safe_client.rb
78
77
  - lib/cassandra/time.rb
79
78
  - lib/cassandra/uuid.rb
80
79
  files:
@@ -97,7 +96,6 @@ files:
97
96
  - lib/cassandra/long.rb
98
97
  - lib/cassandra/ordered_hash.rb
99
98
  - lib/cassandra/protocol.rb
100
- - lib/cassandra/safe_client.rb
101
99
  - lib/cassandra/time.rb
102
100
  - lib/cassandra/uuid.rb
103
101
  - test/cassandra_test.rb
@@ -136,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
134
  requirements: []
137
135
 
138
136
  rubyforge_project: fauna
139
- rubygems_version: 1.3.4
137
+ rubygems_version: 1.3.5
140
138
  signing_key:
141
139
  specification_version: 3
142
140
  summary: A Ruby client for the Cassandra distributed database.
metadata.gz.sig CHANGED
Binary file
@@ -1,26 +0,0 @@
1
-
2
- module CassandraThrift #:nodoc: all
3
- module Cassandra
4
-
5
- class SafeClient
6
- def initialize(client, transport, reset = false)
7
- @client = client
8
- @transport = transport
9
- @reset = reset
10
- end
11
-
12
- def reset_transport
13
- @transport.close rescue nil
14
- @transport.open
15
- end
16
-
17
- def method_missing(*args)
18
- reset_transport if @reset
19
- @client.send(*args)
20
- rescue IOError, UnavailableException, Thrift::ProtocolException, Thrift::ApplicationException, Thrift::TransportException
21
- reset_transport
22
- @client.send(*args)
23
- end
24
- end
25
- end
26
- end