commit: f18e7249b6615030030260b68f52cdf31f45e915
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 03:32:51 2015 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Feb 24 03:32:51 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/ag.git;a=commit;h=f18e7249
Almost ready for real state.
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
---
lib/storage.rb | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
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