class Elasticsearch::Drain::Nodes
Attributes
info[R]
@!attribute [r] The Elasticsearch
node info json object
stats[R]
@!attribute [r] The Elasticsearch
node stats json object
Public Class Methods
new(client, asg)
click to toggle source
Calls superclass method
Elasticsearch::Drain::Base::new
# File lib/elasticsearch/drain/nodes.rb, line 12 def initialize(client, asg) super(client) @asg = asg load end
Public Instance Methods
filter_nodes(instances, reload = false)
click to toggle source
# 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()
click to toggle source
# 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)
click to toggle source
Get list of nodes in the cluster
@return [Array<OpenStruct>] Array of node objects
# 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