es_dump_restore 0.0.8 → 0.0.10

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: 25b8f8d2c2f59f52f984d2fadbd629977f89d00f
4
- data.tar.gz: ceabcfcc74883b3661b9d032743783d1e09aa365
3
+ metadata.gz: 08fa2b9eb215b8ff28dc83c19a9c4b1e952d32ff
4
+ data.tar.gz: febbb67ee5b1faf6157d65323da09177e7e50a91
5
5
  SHA512:
6
- metadata.gz: 191dbeb2a56e3e4ff754f0d9afa8ab673fac01a8c685f499e74dde58ef325c8736a14622a77ca6289898dfb80b6500267c3ba785de1dc8bc7dad715f14effb39
7
- data.tar.gz: b894f31f696b91dd24096eebd7094d679f304b924fc8b30ee073460a2f9b12cfa2bd6011a4fa04cfaa379762d41e380d9726c77951d23b0e4dc1547ae43bb2ae
6
+ metadata.gz: ee784a1b7992d131ebcabd70f7be9d6740597c6ab0339a55db6423cb140a05468113fba1e081cdf3d5fcb51ace39b102077ac24bd9d95f1cb9bae898985ddce5
7
+ data.tar.gz: 108636726d2ee7780cdd350e2e39c5218b3c9d557680cc4eb30c17ce36e11f99aba734cffbe25741efa64d7e8c57cdbf9c171191e2bbb96b7eabcbbed0ac51f4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # Version 0.0.10 - December 3, 2014
2
+
3
+ * Fixes a bug introduced in 0.0.9 (thanks again to Noa Resare for the fix!)
4
+
5
+ # Version 0.0.9 - December 2, 2014 - YANKED
6
+
7
+ * Makes it possible to use ES instances not located at server root (thanks Noa Resare for the patch!)
8
+
1
9
  # Version 0.0.8 - September 9, 2014
2
10
 
3
11
  * Added --noprogressbar option for easier usage with cron (thanks Marco Dickert for the patch!)
@@ -8,6 +8,7 @@ module EsDumpRestore
8
8
  class App < Thor
9
9
 
10
10
  option :noprogressbar, :type => :boolean # switch for showing progress bar
11
+ option :verbose, :type => :boolean # add some additional output
11
12
 
12
13
  desc "dump URL INDEX_NAME FILENAME", "Creates a dumpfile based on the given ElasticSearch index"
13
14
  def dump(url, index_name, filename)
@@ -11,19 +11,20 @@ module EsDumpRestore
11
11
  @httpclient = HTTPClient.new
12
12
  @index_name = index_name
13
13
 
14
- @base_uri = type.nil? ? URI.parse(base_uri + "/" + index_name + "/") : URI.parse(base_uri + "/" + index_name + "/" + type + "/")
14
+ @es_uri = base_uri
15
+ @path_prefix = type.nil? ? index_name : index_name + "/" + type
15
16
  end
16
17
 
17
18
  def mappings
18
- request(:get, '_mapping')[index_name]
19
+ request(:get, "#{@path_prefix}/_mapping")[index_name]
19
20
  end
20
21
 
21
22
  def settings
22
- request(:get, '_settings')[index_name]
23
+ request(:get, "#{@path_prefix}/_settings")[index_name]
23
24
  end
24
25
 
25
26
  def start_scan(&block)
26
- scroll = request(:get, '_search',
27
+ scroll = request(:get, "#{@path_prefix}/_search",
27
28
  query: { search_type: 'scan', scroll: '10m', size: 500 },
28
29
  body: MultiJson.dump({ query: { match_all: {} } }) )
29
30
  total = scroll["hits"]["total"]
@@ -34,9 +35,9 @@ module EsDumpRestore
34
35
 
35
36
  def each_scroll_hit(scroll_id, &block)
36
37
  loop do
37
- batch = request(:get, '/_search/scroll', query: {
38
+ batch = request(:get, '_search/scroll', {query: {
38
39
  scroll: '10m', scroll_id: scroll_id
39
- })
40
+ }}, [404])
40
41
 
41
42
  batch_hits = batch["hits"]
42
43
  break if batch_hits.nil?
@@ -59,10 +60,19 @@ module EsDumpRestore
59
60
 
60
61
  private
61
62
 
62
- def request(method, path, options={})
63
- request_uri = @base_uri + path
64
- response = @httpclient.request(method, request_uri, options)
65
- MultiJson.load(response.content)
63
+ def request(method, path, options={}, extra_allowed_exitcodes=[])
64
+ request_uri = @es_uri + "/" + path
65
+ begin
66
+ response = @httpclient.request(method, request_uri, options)
67
+ unless response.ok? or extra_allowed_exitcodes.include? response.status
68
+ raise "Request failed with status #{response.status}: #{response.reason}"
69
+ end
70
+ MultiJson.load(response.content)
71
+ rescue Exception => e
72
+ puts "Exception caught issuing HTTP request to #{request_uri}"
73
+ puts "options: #{options}"
74
+ raise e
75
+ end
66
76
  end
67
77
  end
68
- end
78
+ end
@@ -1,3 +1,3 @@
1
1
  module EsDumpRestore
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: es_dump_restore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Budin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-09 00:00:00.000000000 Z
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json