elasticshelf 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/examples/wither_older_than_days.rb +49 -13
- data/lib/elasticshelf.rb +16 -7
- data/lib/elasticshelf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17341df9c00b09d1a9627fedc1b198469cdd7873
|
4
|
+
data.tar.gz: 32c212f38fe54af22d16159dfadfe5948bafc226
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 309f27d6d4b3bdc13222b2ab84f9d578ab1f0882abb2a8e86d7a657854e8084e8921ad1d46c700e86a039c96b033b9541c67d99c4958e381a80b136b38a6fdd1
|
7
|
+
data.tar.gz: 646a30138b4cdea5c0d1f99dd9a2c8b2b255a0ae29d820eca3f6d632ccec048797664a9216f2f61756fe94386824281004951a32204fd45f737cddfb67939a2c
|
data/README.md
CHANGED
@@ -172,6 +172,17 @@ es.snapshot = 'name_of_this_snapshot'
|
|
172
172
|
es.snapshot_delete
|
173
173
|
```
|
174
174
|
|
175
|
+
### Snapshot restore
|
176
|
+
|
177
|
+
```
|
178
|
+
es.repo = 'name_of_the_snapshot_repository'
|
179
|
+
es.snapshot = "name_of_this_snapshot"
|
180
|
+
es.indices = "index1"
|
181
|
+
es.snapshot_restore
|
182
|
+
puts "errors=#{es.errors.inspect}"
|
183
|
+
puts "results=#{es.results.inspect}"
|
184
|
+
```
|
185
|
+
|
175
186
|
### Other usage
|
176
187
|
|
177
188
|
```
|
@@ -1,17 +1,53 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Example: for use as a Resque job
|
2
|
+
# test in console to simulate resque job:
|
3
|
+
# turn off sql printing in rails console so we can see "puts" clearly:
|
4
|
+
# ActiveRecord::Base.logger = ::Logger.new(nil)
|
5
|
+
# bundle exec rails c
|
6
|
+
# ew = EsWither.new
|
7
|
+
# ew.wither_old_indices
|
3
8
|
|
4
|
-
|
5
|
-
|
6
|
-
exit(1)
|
7
|
-
end
|
8
|
-
days = ARGV[0].to_i
|
9
|
+
class EsWither
|
10
|
+
require 'elasticshelf'
|
9
11
|
|
10
|
-
|
12
|
+
# this allows us to pass in different methods to perform from the Resque config/schedule.yml:
|
13
|
+
class << self
|
14
|
+
def perform(method)
|
15
|
+
self.new.send(method)
|
16
|
+
end
|
17
|
+
end
|
11
18
|
|
12
|
-
|
13
|
-
#
|
14
|
-
|
19
|
+
def initialize
|
20
|
+
puts "#{Time.now.utc} EsWither::initialize:"
|
21
|
+
@es = Elasticshelf::Client.new(:host => "#{APP_CONFIG[:elasticsearch_host]}:#{APP_CONFIG[:elasticsearch_port]}")
|
22
|
+
@es.repo = "#{APP_CONFIG[:elasticsearch_host]}}_logs"
|
23
|
+
@es.indices_prefix = "#{APP_CONFIG[:elasticsearch_host]}_logs-"
|
24
|
+
puts "\trepo=#{@es.repo}"
|
25
|
+
puts "\tindices_prefix=#{@es.indices_prefix}"
|
26
|
+
end
|
15
27
|
|
16
|
-
|
17
|
-
|
28
|
+
def wither_old_indices
|
29
|
+
puts "#{Time.now.utc} EsWither::wither_old_indices: starting . . ."
|
30
|
+
start_time = Time.now.utc
|
31
|
+
@es.cutoff_days = 3
|
32
|
+
puts "\tcutoff date=#{@es.cutoff_days_as_date_to_s}"
|
33
|
+
# ************************
|
34
|
+
@es.wither_expired_indices
|
35
|
+
# ************************
|
36
|
+
puts "\tindices_withered: #{@es.indices_withered.inspect}"
|
37
|
+
puts "expired_indices:"
|
38
|
+
@es.expired_indices.each { |k,v| puts "\t#{k}=#{v}" }
|
39
|
+
puts "indices_rejected:"
|
40
|
+
@es.indices_rejected.each
|
41
|
+
puts "indices_affected:"
|
42
|
+
@es.indices_affected.each { |k,v| puts "\t#{k}=#{v}" }
|
43
|
+
puts "indices: #{@es.indices.inspect}"
|
44
|
+
# verify bloom filter was disabled:
|
45
|
+
@es.indices_withered.each do |k,v|
|
46
|
+
@es.get_settings_index(k)
|
47
|
+
puts "\tverifying index '#{k}' is withered"
|
48
|
+
puts "\terrors=#{@es.errors.inspect}"
|
49
|
+
puts "\tresults=#{@es.results.inspect}"
|
50
|
+
end
|
51
|
+
puts "#{Time.now.utc} EsWither::wither_old_indices: finished in #{Time.now.utc - start_time} secs"
|
52
|
+
end
|
53
|
+
end
|
data/lib/elasticshelf.rb
CHANGED
@@ -75,8 +75,11 @@ module Elasticshelf
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def index_closed?(index_name)
|
78
|
-
|
79
|
-
|
78
|
+
# catch exceptions when index doesn't exist
|
79
|
+
try do
|
80
|
+
index_metadata = @client.cluster.state(:index => index_name, :metric => 'metadata')
|
81
|
+
index_metadata['metadata']['indices'][index_name]['state'] == 'close'
|
82
|
+
end
|
80
83
|
end
|
81
84
|
|
82
85
|
def open_index(index_name)
|
@@ -120,7 +123,9 @@ module Elasticshelf
|
|
120
123
|
|
121
124
|
def get_settings_index(index_name)
|
122
125
|
reset_errors_results
|
123
|
-
|
126
|
+
try do
|
127
|
+
@results[index_name] = @client.indices.get_settings(:index => index_name)
|
128
|
+
end
|
124
129
|
end
|
125
130
|
|
126
131
|
def wither_index(index_name)
|
@@ -145,13 +150,17 @@ module Elasticshelf
|
|
145
150
|
end
|
146
151
|
|
147
152
|
def get_index_state(index_name, metric='metadata')
|
148
|
-
|
149
|
-
|
153
|
+
try do
|
154
|
+
index_metadata = @client.cluster.state(:index => index_name, :metric => metric)
|
155
|
+
index_metadata['metadata']['indices'][index_name]['state']
|
156
|
+
end
|
150
157
|
end
|
151
158
|
|
152
159
|
def get_cluster_state(index_name, metric='metadata')
|
153
|
-
|
154
|
-
|
160
|
+
try do
|
161
|
+
index_metadata = @client.cluster.state(:index => index_name, :metric => metric)
|
162
|
+
index_metadata
|
163
|
+
end
|
155
164
|
end
|
156
165
|
|
157
166
|
def snapshot_create_repository
|
data/lib/elasticshelf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticshelf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cLee Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|