diff options
author | 2015-02-23 19:32:51 -0800 | |
---|---|---|
committer | 2015-02-23 19:32:51 -0800 | |
commit | f18e7249b6615030030260b68f52cdf31f45e915 (patch) | |
tree | 90984d4913462472e1dfe8fc2c30de3524aeffff | |
parent | more print. (diff) | |
download | backend-f18e7249b6615030030260b68f52cdf31f45e915.tar.gz backend-f18e7249b6615030030260b68f52cdf31f45e915.tar.bz2 backend-f18e7249b6615030030260b68f52cdf31f45e915.zip |
Almost ready for real state.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r-- | lib/storage.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/storage.rb b/lib/storage.rb index 8828bf6..7ec0861 100644 --- a/lib/storage.rb +++ b/lib/storage.rb @@ -5,6 +5,21 @@ require 'pp' module Ag::Storage module_function + def index_states(indexname) + status = $es.indices.status(index: indexname) + states = status['indices'][indexname]['shards'].map do |key,array| + array.map do |v| + v['routing']['state'] + end.flatten + end.flatten + end + def index_ready?(indexname) + states = index_states(indexname) + not_ready = states.include? 'INITIALIZING' or states.include? 'RELOCATING' + return !not_ready + pp $es.cluster.health(level: indices) + end + # Throws Elasticsearch::Transport::Transport::Errors::NotFound # if the list does not exist def delete_index(list) @@ -88,6 +103,7 @@ module Ag::Storage } }) + pp $es.cluster.health(level: indices) # Give elasticsearch some time to process the new index status = $es.indices.status(index: indexname) while $es.cluster.health['status'] != 'green' do |