right_support 2.8.15 → 2.8.16

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.8.15
1
+ 2.8.16
@@ -142,13 +142,20 @@ module RightSupport::DB
142
142
  class CassandraModel
143
143
  include RightSupport::Log::Mixin
144
144
 
145
+ # For long-running operations, generate period log output after this many columns to help
146
+ # observers figure out how much progress has been made
147
+ LONG_OPERATION_LOG_PERIOD = 1_000_000
148
+
145
149
  # Default timeout for client connection to Cassandra server
146
150
  DEFAULT_TIMEOUT = 20
147
151
 
148
- # Default maximum number of rows to retrieve in one chunk
152
+ # Default maximum number of columns to retrieve in one chunk
149
153
  DEFAULT_COUNT = 100
150
154
 
151
- # Wrappers for Cassandra client
155
+ # Default maximum number of rows to retrieve in one chunk
156
+ DEFAULT_ROW_COUNT = 100
157
+
158
+ # Wrappers for Cassandra client
152
159
  class << self
153
160
 
154
161
  attr_reader :default_keyspace
@@ -420,11 +427,11 @@ module RightSupport::DB
420
427
  # A row key may be yielded more than once as each "chunk" of columns from that row is
421
428
  # read from the ring, but each column will be yielded exactly once.
422
429
  #
423
- # == Parameters:
430
+ # @return [Integer] total number of columns read
431
+ #
424
432
  # @param [String] index column name
425
433
  # @param [String] index column value
426
434
  #
427
- # == Yields:
428
435
  # @yield [row_key, columns] yields one or more times for every row that contains a matching index column, ultimately yielding EVERY column in that row
429
436
  # @yieldparam [String] row_key the row key currently being processes
430
437
  # @yieldparam [Array] columns an array of Cassandra CassandraThrift::ColumnOrSuperColumn objects
@@ -432,12 +439,18 @@ module RightSupport::DB
432
439
  expr = do_op(:create_idx_expr, index, key, "EQ")
433
440
  start_row = ''
434
441
 
442
+ last_report = 0
443
+ total_rows = 0
444
+ total_columns = 0
445
+
435
446
  # Loop over all CF rows, with batches of X
436
447
  while (start_row != nil)
437
448
  # Reset these to their initial values on every iteration thru the loop, in case
438
449
  # we backed off due to timeouts (see rescue clauses below)
439
- row_count = 100 # how many rows to grab at once
440
- column_count = 1000 # how much to grab in each chunk of a long row
450
+ #
451
+ # Since this method is made for wide rows, also ask for 10x the default column count.
452
+ row_count = DEFAULT_ROW_COUNT
453
+ column_count = DEFAULT_COUNT * 10
441
454
 
442
455
  clause = do_op(:create_idx_clause, [expr], start_row, row_count)
443
456
 
@@ -460,6 +473,7 @@ module RightSupport::DB
460
473
  # We already processed this row the previous iteration; skip it
461
474
  next if row_key == start_row
462
475
 
476
+ total_rows += 1
463
477
  start_column = ''
464
478
 
465
479
  while start_column != nil
@@ -475,11 +489,20 @@ module RightSupport::DB
475
489
  columns = self.conn.get_range(column_family, options).first.columns
476
490
 
477
491
  if columns[0].column.name == start_column
492
+ total_columns += columns.size - 1
478
493
  yield(row_key, columns[1..-1])
479
494
  else
495
+ total_columns += columns.size
480
496
  yield(row_key, columns)
481
497
  end
482
498
 
499
+ # Help Ops figure out where we are
500
+ if (total_columns - last_report > LONG_OPERATION_LOG_PERIOD)
501
+ logger.info "CassandraModel#stream_all_indexed_slices got RangeSlice total_rows=%d total_columns=%d (cf='%s' row='%s' start='%s' count=%d)" %
502
+ [total_rows, total_columns, column_family, row_key, start_column, column_count]
503
+ last_report = total_columns
504
+ end
505
+
483
506
  if columns.size >= column_count
484
507
  start_column = columns.last.column.name
485
508
  else
@@ -488,7 +511,7 @@ module RightSupport::DB
488
511
  rescue Exception => e
489
512
  if retryable_read_timeout?(e)
490
513
  logger.error "CassandraModel#stream_all_indexed_slices retrying get_range with fewer cols due to a %s: %s @ %s (cf='%s' row='%s' start='%s' count=%d)" %
491
- [e.class.name, e.message, e.backtrace.first, column_family, row_key, last_column_name, column_count]
514
+ [e.class.name, e.message, e.backtrace.first, column_family, row_key, start_column, column_count]
492
515
  column_count /= 10 if column_count > 1
493
516
  retry
494
517
  else
@@ -504,6 +527,8 @@ module RightSupport::DB
504
527
  start_row = nil
505
528
  end
506
529
  end
530
+
531
+ total_columns
507
532
  end
508
533
 
509
534
  # Get all rows for specified secondary key
@@ -124,11 +124,14 @@ module RightSupport::Net
124
124
  class HTTPClient
125
125
  # The default options for every request; can be overridden by options
126
126
  # passed to #initialize or to the individual request methods (#get,
127
- # #post, and so forth).
127
+ # #post, and so forth).
128
+ # NOTE: rest-client 1.6.7 doesn't pass down the ssl_version to Net::HTTP.
129
+ # silently discarded. 1.7.0.alpha or later does.
128
130
  DEFAULT_OPTIONS = {
129
131
  :timeout => 5,
130
132
  :open_timeout => 2,
131
- :headers => {}
133
+ :headers => {},
134
+ :ssl_version => 'TLSv1'
132
135
  }
133
136
 
134
137
  def initialize(defaults = {})
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "right_support"
8
- s.version = "2.8.15"
7
+ s.name = %q{right_support}
8
+ s.version = "2.8.16"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tony Spataro", "Sergey Sergyenko", "Ryan Williamson", "Lee Kirchhoff", "Alexey Karpik", "Scott Messier"]
12
- s.date = "2014-02-26"
13
- s.description = "A toolkit of useful, reusable foundation code created by RightScale."
14
- s.email = "support@rightscale.com"
12
+ s.date = %q{2014-02-27}
13
+ s.description = %q{A toolkit of useful, reusable foundation code created by RightScale.}
14
+ s.email = %q{support@rightscale.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.rdoc"
@@ -134,11 +134,11 @@ Gem::Specification.new do |s|
134
134
  "spec/validation/openssl_spec.rb",
135
135
  "spec/validation/ssh_spec.rb"
136
136
  ]
137
- s.homepage = "https://github.com/rightscale/right_support"
137
+ s.homepage = %q{https://github.com/rightscale/right_support}
138
138
  s.licenses = ["MIT"]
139
139
  s.require_paths = ["lib"]
140
- s.rubygems_version = "1.8.28"
141
- s.summary = "Reusable foundation code."
140
+ s.rubygems_version = %q{1.6.2}
141
+ s.summary = %q{Reusable foundation code.}
142
142
 
143
143
  if s.respond_to? :specification_version then
144
144
  s.specification_version = 3
@@ -270,27 +270,6 @@ describe RightSupport::DB::CassandraModel do
270
270
  end
271
271
  end
272
272
 
273
- def real_get_indexed(index, key, columns = nil, opt = {})
274
- rows = {}
275
- start = ""
276
- count = DEFAULT_COUNT
277
- expr = do_op(:create_idx_expr, index, key, "EQ")
278
- opt = opt[:consistency] ? {:consistency => opt[:consistency]} : {}
279
- while true
280
- clause = do_op(:create_idx_clause, [expr], start, count)
281
- chunk = do_op(:get_indexed_slices, column_family, clause, columns, opt)
282
- rows.merge!(chunk)
283
- if chunk.size == count
284
- # Assume there are more chunks, use last key as start of next get
285
- start = chunk.keys.last
286
- else
287
- # This must be the last chunk
288
- break
289
- end
290
- end
291
- rows
292
- end
293
-
294
273
  context :get_indexed do
295
274
 
296
275
  before(:each) do
@@ -347,6 +326,12 @@ describe RightSupport::DB::CassandraModel do
347
326
  RightSupport::DB::CassandraModel.get_indexed(@index, @index_key).should == []
348
327
  end
349
328
  end
329
+
330
+ context :stream_all_indexed_slices do
331
+ it 'streams rows in chunks'
332
+ it 'streams columns in chunks'
333
+ it 'handles timeouts'
334
+ end
350
335
  end
351
336
  end
352
337
 
@@ -97,6 +97,7 @@ describe RightSupport::Net::HTTPClient do
97
97
  it 'uses default options on every request' do
98
98
  p = {:method=>:get,
99
99
  :timeout=>101010,
100
+ :ssl_version=>'TLSv1',
100
101
  :open_timeout=>999,
101
102
  :url=>'/moo', :headers=>{:moo=>:bah}}
102
103
  flexmock(RestClient::Request).should_receive(:execute).with(p)
@@ -106,10 +107,11 @@ describe RightSupport::Net::HTTPClient do
106
107
  it 'allows defaults to be overridden' do
107
108
  p = {:method=>:get,
108
109
  :timeout=>101010,
110
+ :ssl_version=>'SSLv3',
109
111
  :open_timeout=>3,
110
112
  :url=>'/moo', :headers=>{:joe=>:blow}}
111
113
  flexmock(RestClient::Request).should_receive(:execute).with(p)
112
- @http_client.get('/moo', :open_timeout=>3, :headers=>{:joe=>:blow})
114
+ @http_client.get('/moo', :ssl_version => 'SSLv3', :open_timeout=>3, :headers=>{:joe=>:blow})
113
115
  end
114
116
  end
115
117
  end
@@ -125,6 +127,7 @@ describe RightSupport::Net::HTTPClient do
125
127
  it 'succeeds' do
126
128
  p = {:method=>:get,
127
129
  :timeout=>RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:timeout],
130
+ :ssl_version=>RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:ssl_version],
128
131
  :open_timeout=>RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:open_timeout],
129
132
  :url=>'/moo', :headers=>{}}
130
133
  flexmock(RestClient::Request).should_receive(:execute).with(p)
@@ -137,6 +140,7 @@ describe RightSupport::Net::HTTPClient do
137
140
  it 'succeeds' do
138
141
  p = {:method=>:get,
139
142
  :timeout=>RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:timeout],
143
+ :ssl_version=>RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:ssl_version],
140
144
  :open_timeout=>RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:open_timeout],
141
145
  :url=>'/moo', :headers=>{:mrm=>1, :blah=>:foo}}
142
146
  flexmock(RestClient::Request).should_receive(:execute).with(p)
@@ -150,6 +154,7 @@ describe RightSupport::Net::HTTPClient do
150
154
  it 'succeeds' do
151
155
  p = {:method=>:get,
152
156
  :timeout=>42,
157
+ :ssl_version=>RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:ssl_version],
153
158
  :open_timeout => RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:open_timeout],
154
159
  :url=>'/moo', :headers=>{}}
155
160
  flexmock(RestClient::Request).should_receive(:execute).with(p)
@@ -160,8 +165,13 @@ describe RightSupport::Net::HTTPClient do
160
165
 
161
166
  context 'given a URL and any other parameters' do
162
167
  it 'succeeds' do
163
- p = { :method=>:get, :timeout=>RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:timeout],
164
- :url=>'/moo', :headers=>{},:open_timeout => 1, :payload=>{:foo => :bar} }
168
+ p = { :method=>:get,
169
+ :timeout=>RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:timeout],
170
+ :ssl_version=>RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:ssl_version],
171
+ :url=>'/moo',
172
+ :headers=>{},
173
+ :open_timeout => 1,
174
+ :payload=>{:foo => :bar} }
165
175
  flexmock(RestClient::Request).should_receive(:execute).with(p)
166
176
 
167
177
  @http_client.get('/moo', :open_timeout => 1, :payload=>{:foo => :bar})
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_support
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 8
9
- - 15
10
- version: 2.8.15
9
+ - 16
10
+ version: 2.8.16
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Spataro