riak-client 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.document +5 -5
  3. data/Gemfile +17 -17
  4. data/Guardfile +20 -20
  5. data/LICENSE.md +16 -16
  6. data/README.markdown +1 -1
  7. data/RELEASE_NOTES.md +9 -0
  8. data/lib/riak/client/beefcake/crdt/counter_loader.rb +18 -18
  9. data/lib/riak/client/beefcake/crdt/map_loader.rb +64 -64
  10. data/lib/riak/client/beefcake/footer +4 -4
  11. data/lib/riak/client/beefcake/header +6 -6
  12. data/lib/riak/client/beefcake/messages.rb +0 -16
  13. data/lib/riak/client/decaying.rb +36 -36
  14. data/lib/riak/client/feature_detection.rb +120 -120
  15. data/lib/riak/client/instrumentation.rb +19 -19
  16. data/lib/riak/client/node.rb +49 -49
  17. data/lib/riak/client/search.rb +27 -27
  18. data/lib/riak/conflict.rb +13 -13
  19. data/lib/riak/core_ext.rb +7 -7
  20. data/lib/riak/core_ext/blank.rb +53 -53
  21. data/lib/riak/core_ext/extract_options.rb +7 -7
  22. data/lib/riak/core_ext/json.rb +15 -15
  23. data/lib/riak/core_ext/slice.rb +18 -18
  24. data/lib/riak/core_ext/stringify_keys.rb +10 -10
  25. data/lib/riak/core_ext/symbolize_keys.rb +10 -10
  26. data/lib/riak/core_ext/to_param.rb +31 -31
  27. data/lib/riak/crdt.rb +21 -21
  28. data/lib/riak/crdt/operation.rb +19 -19
  29. data/lib/riak/encoding.rb +6 -6
  30. data/lib/riak/errors/backend_creation.rb +9 -9
  31. data/lib/riak/errors/connection_error.rb +50 -50
  32. data/lib/riak/errors/protobuffs_error.rb +11 -11
  33. data/lib/riak/i18n.rb +7 -7
  34. data/lib/riak/instrumentation.rb +6 -6
  35. data/lib/riak/json.rb +52 -52
  36. data/lib/riak/list_buckets.rb +28 -28
  37. data/lib/riak/locale/fr.yml +51 -51
  38. data/lib/riak/map_reduce/results.rb +49 -49
  39. data/lib/riak/map_reduce_error.rb +7 -7
  40. data/lib/riak/multiget.rb +122 -122
  41. data/lib/riak/stamp.rb +77 -77
  42. data/lib/riak/util/tcp_socket_extensions.rb +58 -58
  43. data/lib/riak/version.rb +1 -1
  44. data/spec/failover/failover.rb +59 -59
  45. data/spec/fixtures/bitcask.txt +25 -25
  46. data/spec/fixtures/multipart-basic-conflict.txt +15 -15
  47. data/spec/fixtures/multipart-blank.txt +7 -7
  48. data/spec/fixtures/multipart-mapreduce.txt +10 -10
  49. data/spec/fixtures/multipart-with-body.txt +16 -16
  50. data/spec/fixtures/multipart-with-marked-tombstones.txt +17 -17
  51. data/spec/fixtures/multipart-with-unmarked-tombstone.txt +16 -16
  52. data/spec/fixtures/server.cert.crt +15 -15
  53. data/spec/fixtures/server.cert.key +15 -15
  54. data/spec/fixtures/test.pem +1 -1
  55. data/spec/integration/riak/threading_spec.rb +150 -150
  56. data/spec/integration/yokozuna/index_spec.rb +61 -61
  57. data/spec/integration/yokozuna/schema_spec.rb +49 -49
  58. data/spec/riak/core_ext/to_param_spec.rb +15 -15
  59. data/spec/riak/crdt/inner_counter_spec.rb +21 -21
  60. data/spec/riak/crdt/inner_set_spec.rb +33 -33
  61. data/spec/riak/crdt/set_spec.rb +61 -61
  62. data/spec/riak/escape_spec.rb +72 -72
  63. data/spec/riak/feature_detection_spec.rb +77 -77
  64. data/spec/riak/index_collection_spec.rb +53 -53
  65. data/spec/riak/instrumentation_spec.rb +124 -124
  66. data/spec/riak/link_spec.rb +85 -85
  67. data/spec/riak/list_buckets_spec.rb +41 -41
  68. data/spec/riak/node_spec.rb +26 -26
  69. data/spec/riak/stamp_spec.rb +54 -54
  70. data/spec/support/certs/README.md +12 -12
  71. data/spec/support/certs/ca.crt +21 -21
  72. data/spec/support/certs/client.crl +13 -13
  73. data/spec/support/certs/client.crt +94 -94
  74. data/spec/support/certs/client.csr +18 -18
  75. data/spec/support/certs/client.key +27 -27
  76. data/spec/support/certs/empty_ca.crt +21 -21
  77. data/spec/support/certs/server.crl +13 -13
  78. data/spec/support/certs/server.crt +94 -94
  79. data/spec/support/certs/server.key +27 -27
  80. data/spec/support/integration_setup.rb +10 -10
  81. data/spec/support/test_client.yml.example +9 -9
  82. metadata +3 -3
@@ -1,120 +1,120 @@
1
- module Riak
2
- class Client
3
- # Methods that can be used to determine whether certain features
4
- # are supported by the Riak node to which the client backend is
5
- # connected.
6
- #
7
- # Backends must implement the "get_server_version" method,
8
- # returning a string representing the Riak node's version. This is
9
- # implemented on HTTP using the stats resource, and on Protocol
10
- # Buffers using the RpbGetServerInfoReq message.
11
- module FeatureDetection
12
- # Constants representing Riak versions
13
- VERSION = {
14
- 1 => Gem::Version.new("1.0.0"),
15
- 1.1 => Gem::Version.new("1.1.0"),
16
- 1.2 => Gem::Version.new("1.2.0"),
17
- 1.3 => Gem::Version.new("1.3.0"),
18
- 1.4 => Gem::Version.new("1.4.0")
19
- }.freeze
20
-
21
- # @return [String] the version of the Riak node
22
- # @abstract
23
- def get_server_version
24
- raise NotImplementedError
25
- end
26
-
27
- # @return [Gem::Version] the version of the Riak node to which
28
- # this backend is connected
29
- def server_version
30
- @server_version ||= Gem::Version.new(get_server_version.split("-").first)
31
- end
32
-
33
- # @return [true,false] whether MapReduce requests can be submitted without
34
- # phases.
35
- def mapred_phaseless?
36
- at_least? VERSION[1.1]
37
- end
38
-
39
- # @return [true,false] whether secondary index queries are
40
- # supported over Protocol Buffers
41
- def pb_indexes?
42
- at_least? VERSION[1.2]
43
- end
44
-
45
- # @return [true,false] whether search queries are supported over
46
- # Protocol Buffers
47
- def pb_search?
48
- at_least? VERSION[1.2]
49
- end
50
-
51
- # @return [true,false] whether conditional fetch/store semantics
52
- # are supported over Protocol Buffers
53
- def pb_conditionals?
54
- at_least? VERSION[1]
55
- end
56
-
57
- # @return [true,false] whether additional quorums and FSM
58
- # controls are available, e.g. primary quorums, basic_quorum,
59
- # notfound_ok
60
- def quorum_controls?
61
- at_least? VERSION[1]
62
- end
63
-
64
- # @return [true,false] whether "not found" responses might
65
- # include vclocks
66
- def tombstone_vclocks?
67
- at_least? VERSION[1]
68
- end
69
-
70
- # @return [true,false] whether partial-fetches (vclock and
71
- # metadata only) are supported over Protocol Buffers
72
- def pb_head?
73
- at_least? VERSION[1]
74
- end
75
-
76
- # @return [true,false] whether bucket properties can be cleared
77
- # (reset to defaults) over HTTP
78
- def http_props_clearable?
79
- at_least? VERSION[1.3]
80
- end
81
-
82
- # @return [true,false] whether secondary indexes support
83
- # pagination
84
- def index_pagination?
85
- at_least? VERSION[1.4]
86
- end
87
-
88
- # @return [true,false] whether secondary indexes support
89
- # return_terms
90
- def index_return_terms?
91
- at_least? VERSION[1.4]
92
- end
93
-
94
- # @return [true,false] whether secondary indexes support
95
- # streaming
96
- def index_streaming?
97
- at_least? VERSION[1.4]
98
- end
99
-
100
- # @return [true,false] whether timeouts are accepted for
101
- # object CRUD, key listing, and bucket listing
102
- def key_object_bucket_timeouts?
103
- at_least? VERSION[1.4]
104
- end
105
-
106
- protected
107
- # @return [true,false] whether the server version is the same or
108
- # newer than the requested version
109
- def at_least?(version)
110
- server_version >= version
111
- end
112
-
113
- # Backends should call this when their connection is interrupted
114
- # or reset so as to facilitate rolling upgrades
115
- def reset_server_version
116
- @server_version = nil
117
- end
118
- end
119
- end
120
- end
1
+ module Riak
2
+ class Client
3
+ # Methods that can be used to determine whether certain features
4
+ # are supported by the Riak node to which the client backend is
5
+ # connected.
6
+ #
7
+ # Backends must implement the "get_server_version" method,
8
+ # returning a string representing the Riak node's version. This is
9
+ # implemented on HTTP using the stats resource, and on Protocol
10
+ # Buffers using the RpbGetServerInfoReq message.
11
+ module FeatureDetection
12
+ # Constants representing Riak versions
13
+ VERSION = {
14
+ 1 => Gem::Version.new("1.0.0"),
15
+ 1.1 => Gem::Version.new("1.1.0"),
16
+ 1.2 => Gem::Version.new("1.2.0"),
17
+ 1.3 => Gem::Version.new("1.3.0"),
18
+ 1.4 => Gem::Version.new("1.4.0")
19
+ }.freeze
20
+
21
+ # @return [String] the version of the Riak node
22
+ # @abstract
23
+ def get_server_version
24
+ raise NotImplementedError
25
+ end
26
+
27
+ # @return [Gem::Version] the version of the Riak node to which
28
+ # this backend is connected
29
+ def server_version
30
+ @server_version ||= Gem::Version.new(get_server_version.split("-").first)
31
+ end
32
+
33
+ # @return [true,false] whether MapReduce requests can be submitted without
34
+ # phases.
35
+ def mapred_phaseless?
36
+ at_least? VERSION[1.1]
37
+ end
38
+
39
+ # @return [true,false] whether secondary index queries are
40
+ # supported over Protocol Buffers
41
+ def pb_indexes?
42
+ at_least? VERSION[1.2]
43
+ end
44
+
45
+ # @return [true,false] whether search queries are supported over
46
+ # Protocol Buffers
47
+ def pb_search?
48
+ at_least? VERSION[1.2]
49
+ end
50
+
51
+ # @return [true,false] whether conditional fetch/store semantics
52
+ # are supported over Protocol Buffers
53
+ def pb_conditionals?
54
+ at_least? VERSION[1]
55
+ end
56
+
57
+ # @return [true,false] whether additional quorums and FSM
58
+ # controls are available, e.g. primary quorums, basic_quorum,
59
+ # notfound_ok
60
+ def quorum_controls?
61
+ at_least? VERSION[1]
62
+ end
63
+
64
+ # @return [true,false] whether "not found" responses might
65
+ # include vclocks
66
+ def tombstone_vclocks?
67
+ at_least? VERSION[1]
68
+ end
69
+
70
+ # @return [true,false] whether partial-fetches (vclock and
71
+ # metadata only) are supported over Protocol Buffers
72
+ def pb_head?
73
+ at_least? VERSION[1]
74
+ end
75
+
76
+ # @return [true,false] whether bucket properties can be cleared
77
+ # (reset to defaults) over HTTP
78
+ def http_props_clearable?
79
+ at_least? VERSION[1.3]
80
+ end
81
+
82
+ # @return [true,false] whether secondary indexes support
83
+ # pagination
84
+ def index_pagination?
85
+ at_least? VERSION[1.4]
86
+ end
87
+
88
+ # @return [true,false] whether secondary indexes support
89
+ # return_terms
90
+ def index_return_terms?
91
+ at_least? VERSION[1.4]
92
+ end
93
+
94
+ # @return [true,false] whether secondary indexes support
95
+ # streaming
96
+ def index_streaming?
97
+ at_least? VERSION[1.4]
98
+ end
99
+
100
+ # @return [true,false] whether timeouts are accepted for
101
+ # object CRUD, key listing, and bucket listing
102
+ def key_object_bucket_timeouts?
103
+ at_least? VERSION[1.4]
104
+ end
105
+
106
+ protected
107
+ # @return [true,false] whether the server version is the same or
108
+ # newer than the requested version
109
+ def at_least?(version)
110
+ server_version >= version
111
+ end
112
+
113
+ # Backends should call this when their connection is interrupted
114
+ # or reset so as to facilitate rolling upgrades
115
+ def reset_server_version
116
+ @server_version = nil
117
+ end
118
+ end
119
+ end
120
+ end
@@ -1,19 +1,19 @@
1
- class Riak::Client
2
- include Instrumentable
3
-
4
- client_payload = {client_id: :client_id}
5
-
6
- instrument_method :buckets, 'riak.list_buckets', client_payload
7
- instrument_method :list_buckets, 'riak.list_buckets', client_payload
8
- instrument_method :list_keys, 'riak.list_keys', client_payload
9
- instrument_method :set_bucket_props, 'riak.set_bucket_props', client_payload
10
- instrument_method :get_bucket_props, 'riak.get_bucket_props', client_payload
11
- instrument_method :clear_bucket_props, 'riak.clear_bucket_props', client_payload
12
- instrument_method :get_index, 'riak.get_index', client_payload
13
- instrument_method :store_object, 'riak.store_object', client_payload
14
- instrument_method :get_object, 'riak.get_object', client_payload
15
- instrument_method :reload_object, 'riak.reload_object', client_payload
16
- instrument_method :delete_object, 'riak.delete_object', client_payload
17
- instrument_method :mapred, 'riak.map_reduce', client_payload
18
- instrument_method :ping, 'riak.ping', client_payload
19
- end
1
+ class Riak::Client
2
+ include Instrumentable
3
+
4
+ client_payload = {client_id: :client_id}
5
+
6
+ instrument_method :buckets, 'riak.list_buckets', client_payload
7
+ instrument_method :list_buckets, 'riak.list_buckets', client_payload
8
+ instrument_method :list_keys, 'riak.list_keys', client_payload
9
+ instrument_method :set_bucket_props, 'riak.set_bucket_props', client_payload
10
+ instrument_method :get_bucket_props, 'riak.get_bucket_props', client_payload
11
+ instrument_method :clear_bucket_props, 'riak.clear_bucket_props', client_payload
12
+ instrument_method :get_index, 'riak.get_index', client_payload
13
+ instrument_method :store_object, 'riak.store_object', client_payload
14
+ instrument_method :get_object, 'riak.get_object', client_payload
15
+ instrument_method :reload_object, 'riak.reload_object', client_payload
16
+ instrument_method :delete_object, 'riak.delete_object', client_payload
17
+ instrument_method :mapred, 'riak.map_reduce', client_payload
18
+ instrument_method :ping, 'riak.ping', client_payload
19
+ end
@@ -1,49 +1,49 @@
1
- module Riak
2
- class Client
3
- class Node
4
- # Represents a single riak node in a cluster.
5
-
6
- include Util::Translation
7
- include Util::Escape
8
-
9
- VALID_OPTIONS = [:host, :pb_port]
10
-
11
- # For a score which halves in 10 seconds, choose
12
- # ln(1/2)/10
13
- ERRORS_DECAY_RATE = Math.log(0.5)/10
14
-
15
- # What IP address or hostname does this node listen on?
16
- attr_accessor :host
17
-
18
- # Which port does the protocol buffers interface listen on?
19
- attr_accessor :pb_port
20
-
21
- # A Decaying rate of errors.
22
- attr_reader :error_rate
23
-
24
- def initialize(client, opts = {})
25
- @client = client
26
- @host = opts[:host] || "127.0.0.1"
27
- @pb_port = opts[:pb_port] || 8087
28
-
29
- @error_rate = Decaying.new
30
- end
31
-
32
- def ==(o)
33
- o.kind_of? Node and
34
- @host == o.host and
35
- @pb_port == o.pb_port
36
- end
37
-
38
- # Can this node be used for protocol buffers requests?
39
- def protobuffs?
40
- # TODO: Need to sort out capabilities
41
- true
42
- end
43
-
44
- def inspect
45
- "#<Node #{@host}:#{@pb_port}>"
46
- end
47
- end
48
- end
49
- end
1
+ module Riak
2
+ class Client
3
+ class Node
4
+ # Represents a single riak node in a cluster.
5
+
6
+ include Util::Translation
7
+ include Util::Escape
8
+
9
+ VALID_OPTIONS = [:host, :pb_port]
10
+
11
+ # For a score which halves in 10 seconds, choose
12
+ # ln(1/2)/10
13
+ ERRORS_DECAY_RATE = Math.log(0.5)/10
14
+
15
+ # What IP address or hostname does this node listen on?
16
+ attr_accessor :host
17
+
18
+ # Which port does the protocol buffers interface listen on?
19
+ attr_accessor :pb_port
20
+
21
+ # A Decaying rate of errors.
22
+ attr_reader :error_rate
23
+
24
+ def initialize(client, opts = {})
25
+ @client = client
26
+ @host = opts[:host] || "127.0.0.1"
27
+ @pb_port = opts[:pb_port] || 8087
28
+
29
+ @error_rate = Decaying.new
30
+ end
31
+
32
+ def ==(o)
33
+ o.kind_of? Node and
34
+ @host == o.host and
35
+ @pb_port == o.pb_port
36
+ end
37
+
38
+ # Can this node be used for protocol buffers requests?
39
+ def protobuffs?
40
+ # TODO: Need to sort out capabilities
41
+ true
42
+ end
43
+
44
+ def inspect
45
+ "#<Node #{@host}:#{@pb_port}>"
46
+ end
47
+ end
48
+ end
49
+ end
@@ -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
data/lib/riak/conflict.rb CHANGED
@@ -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