class Elasticsearch::Drain::Cluster
Public Instance Methods
cluster()
click to toggle source
Elasticsearch
Cluster
Object
# File lib/elasticsearch/drain/cluster.rb, line 8 def cluster client.cluster end
currently_draining(exclude_by = '_ip')
click to toggle source
# File lib/elasticsearch/drain/cluster.rb, line 37 def currently_draining(exclude_by = '_ip') settings = cluster.get_settings(:flat_settings => true) settings.fetch('transient', {}).fetch("cluster.routing.allocation.exclude.#{exclude_by}", nil) end
drain_nodes(nodes, exclude_by = '_ip')
click to toggle source
# File lib/elasticsearch/drain/cluster.rb, line 29 def drain_nodes(nodes, exclude_by = '_ip') cluster.put_settings( body: { transient: { "cluster.routing.allocation.exclude.#{exclude_by}" => nodes } } ) end
health(opts = {})
click to toggle source
# File lib/elasticsearch/drain/cluster.rb, line 12 def health(opts = {}) default_opts = { wait_for_status: 'green' } opts = default_opts.merge(opts) cluster.health(opts) end
healthy?()
click to toggle source
# File lib/elasticsearch/drain/cluster.rb, line 20 def healthy? health['status'] == 'green' end
relocating_shards?()
click to toggle source
# File lib/elasticsearch/drain/cluster.rb, line 24 def relocating_shards? return true unless healthy? health(wait_for_relocating_shards: 3)['relocating_shards'] >= 3 end