Class: Elasticsearch::Drain::Cluster
- Inherits:
-
Base
- Object
- Base
- Elasticsearch::Drain::Cluster
show all
- Defined in:
- lib/elasticsearch/drain/cluster.rb
Instance Attribute Summary
Attributes inherited from Base
#client
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#cluster ⇒ Object
Elasticsearch Cluster Object
8
9
10
|
# File 'lib/elasticsearch/drain/cluster.rb', line 8
def cluster
client.cluster
end
|
#currently_draining(exclude_by = '_ip') ⇒ Object
37
38
39
40
|
# 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') ⇒ Object
29
30
31
32
33
34
35
|
# 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 = {}) ⇒ Object
12
13
14
15
16
17
18
|
# 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? ⇒ Boolean
20
21
22
|
# File 'lib/elasticsearch/drain/cluster.rb', line 20
def healthy?
health['status'] == 'green'
end
|
#relocating_shards? ⇒ Boolean
24
25
26
27
|
# 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
|