riak-client 2.4.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.document +5 -5
  3. data/.gitignore +3 -0
  4. data/Gemfile +17 -17
  5. data/Guardfile +20 -20
  6. data/LICENSE.md +16 -16
  7. data/RELNOTES.md +4 -0
  8. data/Rakefile +6 -1
  9. data/lib/riak/client/beefcake/crdt/counter_loader.rb +18 -18
  10. data/lib/riak/client/beefcake/crdt/hyper_log_log_loader.rb +18 -0
  11. data/lib/riak/client/beefcake/crdt/map_loader.rb +64 -64
  12. data/lib/riak/client/beefcake/crdt_loader.rb +4 -1
  13. data/lib/riak/client/beefcake/crdt_operator.rb +13 -0
  14. data/lib/riak/client/beefcake/footer +4 -4
  15. data/lib/riak/client/beefcake/header +6 -6
  16. data/lib/riak/client/beefcake/messages.rb +67 -10
  17. data/lib/riak/client/decaying.rb +36 -36
  18. data/lib/riak/client/feature_detection.rb +120 -120
  19. data/lib/riak/client/instrumentation.rb +19 -19
  20. data/lib/riak/client/node.rb +49 -49
  21. data/lib/riak/client/search.rb +27 -27
  22. data/lib/riak/conflict.rb +13 -13
  23. data/lib/riak/core_ext.rb +7 -7
  24. data/lib/riak/core_ext/blank.rb +53 -53
  25. data/lib/riak/core_ext/extract_options.rb +7 -7
  26. data/lib/riak/core_ext/json.rb +15 -15
  27. data/lib/riak/core_ext/slice.rb +18 -18
  28. data/lib/riak/core_ext/stringify_keys.rb +10 -10
  29. data/lib/riak/core_ext/symbolize_keys.rb +10 -10
  30. data/lib/riak/core_ext/to_param.rb +31 -31
  31. data/lib/riak/crdt.rb +23 -21
  32. data/lib/riak/crdt/base.rb +1 -1
  33. data/lib/riak/crdt/hyper_log_log.rb +97 -0
  34. data/lib/riak/crdt/operation.rb +19 -19
  35. data/lib/riak/encoding.rb +6 -6
  36. data/lib/riak/errors/backend_creation.rb +9 -9
  37. data/lib/riak/errors/connection_error.rb +50 -50
  38. data/lib/riak/errors/protobuffs_error.rb +11 -11
  39. data/lib/riak/i18n.rb +7 -7
  40. data/lib/riak/instrumentation.rb +6 -6
  41. data/lib/riak/json.rb +52 -52
  42. data/lib/riak/list_buckets.rb +28 -28
  43. data/lib/riak/locale/en.yml +1 -0
  44. data/lib/riak/locale/fr.yml +51 -51
  45. data/lib/riak/map_reduce/results.rb +49 -49
  46. data/lib/riak/map_reduce_error.rb +7 -7
  47. data/lib/riak/multiget.rb +122 -122
  48. data/lib/riak/robject.rb +17 -1
  49. data/lib/riak/search/result_document.rb +9 -0
  50. data/lib/riak/stamp.rb +77 -77
  51. data/lib/riak/tombstone.rb +13 -0
  52. data/lib/riak/util/tcp_socket_extensions.rb +58 -58
  53. data/lib/riak/version.rb +1 -1
  54. data/spec/failover/failover.rb +59 -59
  55. data/spec/fixtures/bitcask.txt +25 -25
  56. data/spec/fixtures/multipart-basic-conflict.txt +15 -15
  57. data/spec/fixtures/multipart-blank.txt +7 -7
  58. data/spec/fixtures/multipart-mapreduce.txt +10 -10
  59. data/spec/fixtures/multipart-with-body.txt +16 -16
  60. data/spec/fixtures/multipart-with-marked-tombstones.txt +17 -17
  61. data/spec/fixtures/multipart-with-unmarked-tombstone.txt +16 -16
  62. data/spec/fixtures/server.cert.crt +15 -15
  63. data/spec/fixtures/server.cert.key +15 -15
  64. data/spec/fixtures/test.pem +1 -1
  65. data/spec/integration/riak/bucket_types_spec.rb +38 -0
  66. data/spec/integration/riak/crdt/configuration_spec.rb +4 -3
  67. data/spec/integration/riak/crdt_spec.rb +70 -0
  68. data/spec/integration/riak/encodings/crdt_spec.rb +29 -3
  69. data/spec/integration/riak/encodings/yz_spec.rb +2 -1
  70. data/spec/integration/riak/preflist_spec.rb +15 -3
  71. data/spec/integration/riak/protobuffs/timeouts_spec.rb +1 -1
  72. data/spec/integration/riak/security_spec.rb +11 -6
  73. data/spec/integration/riak/threading_spec.rb +154 -150
  74. data/spec/integration/yokozuna/index_spec.rb +61 -61
  75. data/spec/integration/yokozuna/queries_spec.rb +1 -1
  76. data/spec/integration/yokozuna/schema_spec.rb +49 -49
  77. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +22 -0
  78. data/spec/riak/core_ext/to_param_spec.rb +15 -15
  79. data/spec/riak/crdt/hyper_log_log_spec.rb +56 -0
  80. data/spec/riak/crdt/inner_counter_spec.rb +21 -21
  81. data/spec/riak/crdt/inner_set_spec.rb +33 -33
  82. data/spec/riak/crdt/set_spec.rb +61 -61
  83. data/spec/riak/crdt/shared_examples.rb +14 -0
  84. data/spec/riak/escape_spec.rb +72 -72
  85. data/spec/riak/feature_detection_spec.rb +77 -77
  86. data/spec/riak/index_collection_spec.rb +53 -53
  87. data/spec/riak/instrumentation_spec.rb +124 -124
  88. data/spec/riak/link_spec.rb +85 -85
  89. data/spec/riak/list_buckets_spec.rb +41 -41
  90. data/spec/riak/node_spec.rb +26 -26
  91. data/spec/riak/robject_spec.rb +45 -0
  92. data/spec/support/certs/README.md +12 -12
  93. data/spec/support/certs/ca.crt +21 -21
  94. data/spec/support/certs/client.crl +13 -13
  95. data/spec/support/certs/client.crt +94 -94
  96. data/spec/support/certs/client.csr +18 -18
  97. data/spec/support/certs/client.key +27 -27
  98. data/spec/support/certs/empty_ca.crt +21 -21
  99. data/spec/support/certs/server.crl +13 -13
  100. data/spec/support/certs/server.crt +94 -94
  101. data/spec/support/certs/server.key +27 -27
  102. data/spec/support/crdt_search_fixtures.rb +1 -1
  103. data/spec/support/integration_setup.rb +10 -10
  104. data/spec/support/test_client.rb +1 -1
  105. data/spec/support/test_client.yml.example +10 -10
  106. metadata +10 -3
@@ -1,27 +1,27 @@
1
- module Riak
2
- class Client
3
- # (Riak Search) Performs a search via the Solr interface.
4
- # @overload search(index, query, options={})
5
- # @param [String] index the index to query on
6
- # @param [String] query a Lucene query string
7
- # @overload search(query, options={})
8
- # Queries the default index
9
- # @param [String] query a Lucene query string
10
- # @param [Hash] options extra options for the Solr query
11
- # @option options [String] :df the default field to search in
12
- # @option options [String] :'q.op' the default operator between terms ("or", "and")
13
- # @option options [String] :wt ("json") the response type - "json" and "xml" are valid
14
- # @option options [String] :sort ('none') the field and direction to sort, e.g. "name asc"
15
- # @option options [Fixnum] :start (0) the offset into the query to start from, e.g. for pagination
16
- # @option options [Fixnum] :rows (10) the number of results to return
17
- # @return [Hash] the query result, containing the 'responseHeaders' and 'response' keys
18
- def search(*args)
19
- options = args.extract_options!
20
- index, query = args[-2], args[-1] # Allows nil index, while keeping it as firstargument
21
- backend do |b|
22
- b.search(index, query, options)
23
- end
24
- end
25
- alias :select :search
26
- end
27
- end
1
+ module Riak
2
+ class Client
3
+ # (Riak Search) Performs a search via the Solr interface.
4
+ # @overload search(index, query, options={})
5
+ # @param [String] index the index to query on
6
+ # @param [String] query a Lucene query string
7
+ # @overload search(query, options={})
8
+ # Queries the default index
9
+ # @param [String] query a Lucene query string
10
+ # @param [Hash] options extra options for the Solr query
11
+ # @option options [String] :df the default field to search in
12
+ # @option options [String] :'q.op' the default operator between terms ("or", "and")
13
+ # @option options [String] :wt ("json") the response type - "json" and "xml" are valid
14
+ # @option options [String] :sort ('none') the field and direction to sort, e.g. "name asc"
15
+ # @option options [Fixnum] :start (0) the offset into the query to start from, e.g. for pagination
16
+ # @option options [Fixnum] :rows (10) the number of results to return
17
+ # @return [Hash] the query result, containing the 'responseHeaders' and 'response' keys
18
+ def search(*args)
19
+ options = args.extract_options!
20
+ index, query = args[-2], args[-1] # Allows nil index, while keeping it as firstargument
21
+ backend do |b|
22
+ b.search(index, query, options)
23
+ end
24
+ end
25
+ alias :select :search
26
+ end
27
+ end
@@ -1,13 +1,13 @@
1
- require 'riak/util/translation'
2
-
3
- module Riak
4
- # Raised when an object that is in conflict (i.e. has siblings) is
5
- # stored or manipulated as if it had a single value.
6
- class Conflict < StandardError
7
- include Util::Translation
8
-
9
- def initialize(robject)
10
- super t('object_in_conflict', :robject => robject.inspect)
11
- end
12
- end
13
- end
1
+ require 'riak/util/translation'
2
+
3
+ module Riak
4
+ # Raised when an object that is in conflict (i.e. has siblings) is
5
+ # stored or manipulated as if it had a single value.
6
+ class Conflict < StandardError
7
+ include Util::Translation
8
+
9
+ def initialize(robject)
10
+ super t('object_in_conflict', :robject => robject.inspect)
11
+ end
12
+ end
13
+ end
@@ -1,7 +1,7 @@
1
- require 'riak/core_ext/blank'
2
- require 'riak/core_ext/extract_options'
3
- require 'riak/core_ext/slice'
4
- require 'riak/core_ext/stringify_keys'
5
- require 'riak/core_ext/symbolize_keys'
6
- require 'riak/core_ext/to_param'
7
- require 'riak/core_ext/deep_dup'
1
+ require 'riak/core_ext/blank'
2
+ require 'riak/core_ext/extract_options'
3
+ require 'riak/core_ext/slice'
4
+ require 'riak/core_ext/stringify_keys'
5
+ require 'riak/core_ext/symbolize_keys'
6
+ require 'riak/core_ext/to_param'
7
+ require 'riak/core_ext/deep_dup'
@@ -1,53 +1,53 @@
1
- require 'set'
2
-
3
- unless Object.new.respond_to? :blank?
4
- class Object
5
- def blank?
6
- false
7
- end
8
- end
9
-
10
- class NilClass
11
- def blank?
12
- true
13
- end
14
- end
15
-
16
- class FalseClass
17
- def blank?
18
- true
19
- end
20
- end
21
-
22
- class TrueClass
23
- def blank?
24
- false
25
- end
26
- end
27
-
28
- class Set
29
- alias :blank? :empty?
30
- end
31
-
32
- class String
33
- def blank?
34
- self !~ /[^\s]/
35
- end
36
- end
37
-
38
- class Array
39
- alias :blank? :empty?
40
- end
41
-
42
- class Hash
43
- alias :blank? :empty?
44
- end
45
- end
46
-
47
- unless Object.new.respond_to? :present?
48
- class Object
49
- def present?
50
- !blank?
51
- end
52
- end
53
- end
1
+ require 'set'
2
+
3
+ unless Object.new.respond_to? :blank?
4
+ class Object
5
+ def blank?
6
+ false
7
+ end
8
+ end
9
+
10
+ class NilClass
11
+ def blank?
12
+ true
13
+ end
14
+ end
15
+
16
+ class FalseClass
17
+ def blank?
18
+ true
19
+ end
20
+ end
21
+
22
+ class TrueClass
23
+ def blank?
24
+ false
25
+ end
26
+ end
27
+
28
+ class Set
29
+ alias :blank? :empty?
30
+ end
31
+
32
+ class String
33
+ def blank?
34
+ self !~ /[^\s]/
35
+ end
36
+ end
37
+
38
+ class Array
39
+ alias :blank? :empty?
40
+ end
41
+
42
+ class Hash
43
+ alias :blank? :empty?
44
+ end
45
+ end
46
+
47
+ unless Object.new.respond_to? :present?
48
+ class Object
49
+ def present?
50
+ !blank?
51
+ end
52
+ end
53
+ end
@@ -1,7 +1,7 @@
1
- unless Array.new.respond_to? :extract_options!
2
- class Array
3
- def extract_options!
4
- last.is_a?(::Hash) ? pop : {}
5
- end
6
- end
7
- end
1
+ unless Array.new.respond_to? :extract_options!
2
+ class Array
3
+ def extract_options!
4
+ last.is_a?(::Hash) ? pop : {}
5
+ end
6
+ end
7
+ end
@@ -1,15 +1,15 @@
1
- unless Object.new.respond_to?(:to_json)
2
- # @private
3
- class Object
4
- def to_json(*args)
5
- Riak::JSON.encode(self)
6
- end
7
- end
8
-
9
- # @private
10
- class Symbol
11
- def to_json(*args)
12
- to_s.to_json(*args)
13
- end
14
- end
15
- end
1
+ unless Object.new.respond_to?(:to_json)
2
+ # @private
3
+ class Object
4
+ def to_json(*args)
5
+ Riak::JSON.encode(self)
6
+ end
7
+ end
8
+
9
+ # @private
10
+ class Symbol
11
+ def to_json(*args)
12
+ to_s.to_json(*args)
13
+ end
14
+ end
15
+ end
@@ -1,18 +1,18 @@
1
- unless {}.respond_to? :slice
2
- class Hash
3
- def slice(*keys)
4
- allowed = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
5
- hash = {}
6
- allowed.each { |k| hash[k] = self[k] if has_key?(k) }
7
- hash
8
- end
9
-
10
- def slice!(*keys)
11
- keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
12
- omit = slice(*self.keys - keys)
13
- hash = slice(*keys)
14
- replace(hash)
15
- omit
16
- end
17
- end
18
- end
1
+ unless {}.respond_to? :slice
2
+ class Hash
3
+ def slice(*keys)
4
+ allowed = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
5
+ hash = {}
6
+ allowed.each { |k| hash[k] = self[k] if has_key?(k) }
7
+ hash
8
+ end
9
+
10
+ def slice!(*keys)
11
+ keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
12
+ omit = slice(*self.keys - keys)
13
+ hash = slice(*keys)
14
+ replace(hash)
15
+ omit
16
+ end
17
+ end
18
+ end
@@ -1,10 +1,10 @@
1
- unless {}.respond_to? :stringify_keys
2
- class Hash
3
- def stringify_keys
4
- inject({}) do |hash, pair|
5
- hash[pair[0].to_s] = pair[1]
6
- hash
7
- end
8
- end
9
- end
10
- end
1
+ unless {}.respond_to? :stringify_keys
2
+ class Hash
3
+ def stringify_keys
4
+ inject({}) do |hash, pair|
5
+ hash[pair[0].to_s] = pair[1]
6
+ hash
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,10 +1,10 @@
1
- unless {}.respond_to? :symbolize_keys
2
- class Hash
3
- def symbolize_keys
4
- inject({}) do |hash, pair|
5
- hash[pair[0].to_sym] = pair[1]
6
- hash
7
- end
8
- end
9
- end
10
- end
1
+ unless {}.respond_to? :symbolize_keys
2
+ class Hash
3
+ def symbolize_keys
4
+ inject({}) do |hash, pair|
5
+ hash[pair[0].to_sym] = pair[1]
6
+ hash
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,31 +1,31 @@
1
- unless Object.new.respond_to? :to_query and Object.new.respond_to? :to_param
2
- class Object
3
- def to_param
4
- to_s
5
- end
6
-
7
- def to_query(key)
8
- require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
9
- "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}"
10
- end
11
- end
12
-
13
- class Array
14
- def to_param
15
- map(&:to_param).join('/')
16
- end
17
-
18
- def to_query(key)
19
- prefix = "#{key}[]"
20
- collect { |value| value.to_query(prefix) }.join '&'
21
- end
22
- end
23
-
24
- class Hash
25
- def to_param(namespace = nil)
26
- collect do |key, value|
27
- value.to_query(namespace ? "#{namespace}[#{key}]" : key)
28
- end.sort * '&'
29
- end
30
- end
31
- end
1
+ unless Object.new.respond_to? :to_query and Object.new.respond_to? :to_param
2
+ class Object
3
+ def to_param
4
+ to_s
5
+ end
6
+
7
+ def to_query(key)
8
+ require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
9
+ "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}"
10
+ end
11
+ end
12
+
13
+ class Array
14
+ def to_param
15
+ map(&:to_param).join('/')
16
+ end
17
+
18
+ def to_query(key)
19
+ prefix = "#{key}[]"
20
+ collect { |value| value.to_query(prefix) }.join '&'
21
+ end
22
+ end
23
+
24
+ class Hash
25
+ def to_param(namespace = nil)
26
+ collect do |key, value|
27
+ value.to_query(namespace ? "#{namespace}[#{key}]" : key)
28
+ end.sort * '&'
29
+ end
30
+ end
31
+ end
@@ -1,21 +1,23 @@
1
- require 'riak/errors/crdt_error'
2
-
3
- %w{ operation base inner_register inner_flag counter inner_counter batch_counter map inner_map batch_map set inner_set typed_collection }.each do |f|
4
- require "riak/crdt/#{f}"
5
- end
6
-
7
- module Riak
8
- # Container module for Convergent Replicated Data Type
9
- # features.
10
- module Crdt
11
-
12
- # These are the default bucket types for the three top-level data types.
13
- # Broadly, CRDTs require allow_mult to be enabled, and the `datatype`
14
- # property to be set to the appropriate atom (`counter`, `map`, or `set`).
15
- DEFAULT_BUCKET_TYPES = {
16
- counter: 'counters',
17
- map: 'maps',
18
- set: 'sets',
19
- }
20
- end
21
- end
1
+ require 'riak/errors/crdt_error'
2
+
3
+ %w{ operation base inner_register inner_flag counter inner_counter batch_counter hyper_log_log map inner_map batch_map set inner_set typed_collection }.each do |f|
4
+ require "riak/crdt/#{f}"
5
+ end
6
+
7
+ module Riak
8
+ # Container module for Convergent Replicated Data Type
9
+ # features.
10
+ module Crdt
11
+
12
+ # These are the default bucket types for the three top-level data types.
13
+ # Broadly, CRDTs require allow_mult to be enabled, and the `datatype`
14
+ # property to be set to the appropriate atom (`counter`, `map`, `set`
15
+ # or 'hll').
16
+ DEFAULT_BUCKET_TYPES = {
17
+ counter: 'counters',
18
+ map: 'maps',
19
+ set: 'sets',
20
+ hll: 'hlls',
21
+ }
22
+ end
23
+ end
@@ -2,7 +2,7 @@ module Riak
2
2
  module Crdt
3
3
  # Basic and shared code used by the top-level CRDTs. In particular, dirty-
4
4
  # tracking, loading, and operating is implemented by this class, and
5
- # the {Riak::Crdt::Set}, {Riak::Crdt::Counter}, and {Riak::Crdt::Map}
5
+ # the {Riak::Crdt::Set}, {Riak::Crdt::HyperLogLog}, {Riak::Crdt::Counter}, and {Riak::Crdt::Map}
6
6
  # classes implement everything else.
7
7
  #
8
8
  # @api private