Module: Open
Overview
Index opening operations
Constant Summary
Constants included from Logging
Instance Method Summary collapse
- #do_open(indices) ⇒ Object
- #open ⇒ Object
- #open_populate_indices(indices, date_from, date_to, daysago) ⇒ Object
Methods included from Logging
configure_logger_for, #log, log_level, logger_for
Instance Method Details
#do_open(indices) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/elastic_manager/open.rb', line 37 def do_open(indices) indices.each do |index| next if skip_index?(index, 'open') response = @elastic.request(:get, "/_cat/indices/#{index}") if index_exist?(response) next if already?(response, 'open') elastic_action_with_log('open_index', index) else log.warn "#{index} index not found" log.info "#{index} trying snapshot restore" elastic_action_with_log('restore_snapshot', index, @config['settings']['box_types']['store']) end end end |
#open ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/elastic_manager/open.rb', line 56 def open indices, date_from, date_to, daysago = prepare_vars prechecks(date_from, date_to) indices = open_populate_indices(indices, date_from, date_to, daysago) log.debug indices.inspect do_open(indices) end |
#open_populate_indices(indices, date_from, date_to, daysago) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/elastic_manager/open.rb', line 9 def open_populate_indices(indices, date_from, date_to, daysago) result = [] if indices.length == 1 && indices.first == '_all' result = @elastic.all_indices(date_from, date_to, daysago, 'close', nil, @config) result += @elastic.all_indices_in_snapshots(date_from, date_to, daysago, @config) return result end if date_from.nil? result = @elastic.all_indices(date_from, date_to, daysago, 'close', nil, @config) result += @elastic.all_indices_in_snapshots(date_from, date_to, daysago, @config) return result.select { |r| r.start_with?(*indices) } else date_from.upto(date_to) do |date| indices.each do |index| date_formatted = date.to_s.tr('-', '.') result << "#{index}-#{date_formatted}" end end end return result unless result.empty? log.fatal 'no indices for work' exit 1 end |