Class: Elasticsearch::Drain::Nodes
- Defined in:
- lib/elasticsearch/drain/nodes.rb
Instance Attribute Summary collapse
-
#info ⇒ Object
readonly
The Elasticsearch node info json object.
-
#stats ⇒ Object
readonly
The Elasticsearch node stats json object.
Attributes inherited from Base
Instance Method Summary collapse
- #filter_nodes(instances, reload = false) ⇒ Object
-
#initialize(client, asg) ⇒ Nodes
constructor
A new instance of Nodes.
- #load ⇒ Object
-
#nodes(reload = false) ⇒ Array<OpenStruct>
Get list of nodes in the cluster.
Constructor Details
#initialize(client, asg) ⇒ Nodes
Returns a new instance of Nodes.
12 13 14 15 16 |
# File 'lib/elasticsearch/drain/nodes.rb', line 12 def initialize(client, asg) super(client) @asg = asg load end |
Instance Attribute Details
#info ⇒ Object (readonly)
The Elasticsearch node info json object
10 11 12 |
# File 'lib/elasticsearch/drain/nodes.rb', line 10 def info @info end |
#stats ⇒ Object (readonly)
The Elasticsearch node stats json object
6 7 8 |
# File 'lib/elasticsearch/drain/nodes.rb', line 6 def stats @stats end |
Instance Method Details
#filter_nodes(instances, reload = false) ⇒ Object
41 42 43 |
# File 'lib/elasticsearch/drain/nodes.rb', line 41 def filter_nodes(instances, reload = false) nodes(reload).find_all { |n| instances.include? n.ipaddress } end |
#load ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/elasticsearch/drain/nodes.rb', line 18 def load tries ||= 3 @info = client.nodes.info metric: '_all' @stats = client.nodes.stats metric: '_all' rescue Faraday::TimeoutError retry unless (tries -= 1).zero? end |
#nodes(reload = false) ⇒ Array<OpenStruct>
Get list of nodes in the cluster
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/elasticsearch/drain/nodes.rb', line 29 def nodes(reload = false) load if reload @info['nodes'].map do |node| Drain::Node.new( stats['nodes'].find { |n| n[0] == node[0] }, node, client, @asg ) end end |