elastomer-client 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3bb86cf79cf4c35faa602b5b887790916354830
4
- data.tar.gz: 0d20d421a0c1c396efaaa01edfc0c7eb621deb37
3
+ metadata.gz: 81dcb0ea764810dd5a824281170423608a0ab5f2
4
+ data.tar.gz: 089264a40b4574bccf618b35cc258266bb06ec94
5
5
  SHA512:
6
- metadata.gz: 0043c22c958488f7952e814a05390df0dfb1b3746414b66d33b22ea5951f489155bd2ac820d47c541f9b3146f73a1a7a9c93af0b88769318ff1229bf112a160e
7
- data.tar.gz: ca7cf1438d19f70fa2f73bf4b2ff7a22e8ef74453f8914dfa646b83163b4df0a4216fbd6cc5666b153dc2bcebd3af602f7240f28b449b22f07d61808fd27a608
6
+ metadata.gz: fd7298fd7537c9bcdc07f7be3bae04bcd77c83c20cbd3b0c7e410d339cc55f2ecaebb4f9dd3bc53305705cd19a44311cbd301f4f813c172035e2f36a1d1dcf12
7
+ data.tar.gz: 8eb7574b104215ee1a66a346a29c10d8ee00ea1273a4a213c8756b8ebdb1f07a25c8fe118bccfdca073c6a607e4a77e1bb32e14f999d855e5e9a8b7795c05238
@@ -1,3 +1,9 @@
1
+ ## 0.4.1 (2014-10-14)
2
+ - Support for index `_recovery` endpoint
3
+ - Fix Faraday 0.8 support
4
+ - Wrap all Faraday exceptions
5
+ - Correctly wrap single-command reroute with a command array
6
+
1
7
  ## 0.4.0 (2014-10-08)
2
8
  - BREAKING: docs.add alias for docs.index removed
3
9
  - BREAKING: Faraday exceptions are now raised as Elastomer exceptions
@@ -54,6 +54,7 @@ The event namespace is `request.client.elastomer`.
54
54
  - index.mapping
55
55
  - index.open
56
56
  - index.optimize
57
+ - index.recovery
57
58
  - index.refresh
58
59
  - index.segments
59
60
  - index.snapshot
@@ -187,23 +187,11 @@ module Elastomer
187
187
 
188
188
  handle_errors response
189
189
 
190
- rescue Faraday::Error::TimeoutError => boom
191
- raise TimeoutError.new(boom, method.upcase, path)
192
-
193
- rescue Faraday::Error::ConnectionFailed => boom
194
- raise ConnectionFailed.new(boom, method.upcase, path)
195
-
196
- rescue Faraday::Error::ResourceNotFound => boom
197
- raise ResourceNotFound.new(boom, method.upcase, path)
198
-
199
- rescue Faraday::Error::ParsingError => boom
200
- raise ParsingError.new(boom, method.upcase, path)
201
-
202
- rescue Faraday::Error::SSLError => boom
203
- raise SSLError.new(boom, method.upcase, path)
204
-
190
+ # wrap Faraday errors with appropriate Elastomer::Client error classes
205
191
  rescue Faraday::Error::ClientError => boom
206
- raise Error.new(boom, method.upcase, path)
192
+ error_name = boom.class.name.split('::').last
193
+ error_class = Elastomer::Client.const_get(error_name) rescue Elastomer::Client::Error
194
+ raise error_class.new(boom, method.upcase, path)
207
195
 
208
196
  # ensure
209
197
  # # FIXME: this is here until we get a real logger in place
@@ -129,11 +129,24 @@ module Elastomer
129
129
  # { :allocate => { :index => 'test', :shard => 1, :node => 'node3' }}
130
130
  # ])
131
131
  #
132
+ # reroute(:commands => [
133
+ # { :move => { :index => 'test', :shard => 0, :from_node => 'node1', :to_node => 'node2' }},
134
+ # { :allocate => { :index => 'test', :shard => 1, :node => 'node3' }}
135
+ # ])
136
+ #
132
137
  # See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-reroute.html
133
138
  #
134
139
  # Returns the response as a Hash
135
140
  def reroute( commands, params = {} )
136
- body = {:commands => Array(commands)}
141
+ if commands.is_a?(Hash) && commands.key?(:commands)
142
+ body = commands
143
+ elsif commands.is_a?(Hash)
144
+ # Array() on a Hash does not do what you think it does - that is why
145
+ # we are explicitly wrapping the Hash via [commands] here.
146
+ body = {:commands => [commands]}
147
+ else
148
+ body = {:commands => Array(commands)}
149
+ end
137
150
 
138
151
  response = client.post '/_cluster/reroute', params.merge(:body => body, :action => 'cluster.reroute')
139
152
  response.body
@@ -77,5 +77,16 @@ module Elastomer
77
77
  TimeoutError.fatal = false
78
78
  ConnectionFailed.fatal = false
79
79
 
80
+ # Define an Elastomer::Client exception class on the fly for
81
+ # Faraday exception classes that we don't specifically wrap.
82
+ Faraday::Error.constants.each do |error_name|
83
+ next if ::Elastomer::Client.const_get(error_name) rescue nil
84
+
85
+ error_class = Faraday::Error.const_get(error_name)
86
+ next unless error_class < Faraday::Error::ClientError
87
+
88
+ ::Elastomer::Client.const_set(error_name, Class.new(Error))
89
+ end
90
+
80
91
  end # Client
81
92
  end # Elastomer
@@ -282,6 +282,19 @@ module Elastomer
282
282
  response.body
283
283
  end
284
284
 
285
+ # Provides insight into on-going index shard recoveries. Recovery status
286
+ # may be reported for specific indices, or cluster-wide.
287
+ #
288
+ # See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-recovery.html
289
+ #
290
+ # params - Parameters Hash
291
+ #
292
+ # Returns the response body as a Hash
293
+ def recovery( params = {} )
294
+ response = client.get '{/index}/_recovery', update_params(params, :action => 'index.recovery')
295
+ response.body
296
+ end
297
+
285
298
  # Clear caches for one or more indices. Individual caches can be
286
299
  # specified with parameters.
287
300
  # See http://www.elasticsearch.org/guide/reference/api/admin-indices-clearcache/
@@ -1,5 +1,5 @@
1
1
  module Elastomer
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -240,6 +240,13 @@ describe Elastomer::Client::Index do
240
240
  end
241
241
  end
242
242
 
243
+ if es_version_1_x?
244
+ it 'recovery' do
245
+ response = @index.recovery
246
+ assert_includes response, "elastomer-index-test"
247
+ end
248
+ end
249
+
243
250
  it 'clears caches' do
244
251
  response = @index.clear_cache
245
252
  assert_equal 0, response["_shards"]["failed"]
@@ -27,7 +27,7 @@ describe 'stubbed client tests' do
27
27
 
28
28
  describe Elastomer::Client::Nodes do
29
29
  it 'performs a shutdown of the node(s)' do
30
- @stubs.post('/_cluster/nodes/_shutdown') { [200, {'Content-Type' => 'application/json'}, '{"nodes":{"1":{"name":"Node1"}}}'] }
30
+ @stubs.post('/_cluster/nodes/_all/_shutdown') { [200, {'Content-Type' => 'application/json'}, '{"nodes":{"1":{"name":"Node1"}}}'] }
31
31
  @stubs.post('/_cluster/nodes/node2/_shutdown') { [200, {'Content-Type' => 'application/json'}, '{"nodes":{"2":{"name":"Node2"}}}'] }
32
32
 
33
33
  h = @client.nodes.shutdown
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastomer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Pease
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-08 00:00:00.000000000 Z
12
+ date: 2014-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -176,7 +176,7 @@ files:
176
176
  - test/client/repository_test.rb
177
177
  - test/client/scan_test.rb
178
178
  - test/client/snapshot_test.rb
179
- - test/client/stubbed_client_tests.rb
179
+ - test/client/stubbed_client_test.rb
180
180
  - test/client/template_test.rb
181
181
  - test/client/warmer_test.rb
182
182
  - test/client_test.rb
@@ -221,7 +221,7 @@ test_files:
221
221
  - test/client/repository_test.rb
222
222
  - test/client/scan_test.rb
223
223
  - test/client/snapshot_test.rb
224
- - test/client/stubbed_client_tests.rb
224
+ - test/client/stubbed_client_test.rb
225
225
  - test/client/template_test.rb
226
226
  - test/client/warmer_test.rb
227
227
  - test/client_test.rb