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
38
39
40
41
|
# File 'lib/elasticsearch/drain/cluster.rb', line 38
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
30
31
32
33
34
35
36
|
# File 'lib/elasticsearch/drain/cluster.rb', line 30
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
19
|
# File 'lib/elasticsearch/drain/cluster.rb', line 12
def health(opts = {})
default_opts = {
wait_for_status: 'green',
timeout: 60
}
opts = default_opts.merge(opts)
cluster.health(opts)
end
|
#healthy? ⇒ Boolean
21
22
23
|
# File 'lib/elasticsearch/drain/cluster.rb', line 21
def healthy?
health['status'] == 'green'
end
|
#relocating_shards? ⇒ Boolean
25
26
27
28
|
# File 'lib/elasticsearch/drain/cluster.rb', line 25
def relocating_shards?
return true unless healthy?
health(wait_for_relocating_shards: 3)['relocating_shards'] >= 3
end
|