class Elasticsearch::Drain
Constants
- VERSION
Attributes
hosts[R]
@attribute [r] The Elasticsearch
hosts to connect to
region[R]
@attribute [r] EC2 Region
Public Class Methods
new(hosts = 'localhost:9200', asg = nil, region = nil)
click to toggle source
Sets up the Elasticsearch
client
@option [String] :hosts ('localhost:9200') The Elasticsearch
hosts
to connect to
@return [Elasticsearch::Transport::Client] Elasticsearch
transport client
# File lib/elasticsearch/drain.rb, line 19 def initialize(hosts = 'localhost:9200', asg = nil, region = nil) @hosts = hosts @region = region @asg_name = asg end
Public Instance Methods
active_nodes_in_asg()
click to toggle source
# File lib/elasticsearch/drain.rb, line 53 def active_nodes_in_asg instances = asg.instances nodes.filter_nodes(instances, true) end
asg()
click to toggle source
EC2 AutoScaling
Client
# File lib/elasticsearch/drain.rb, line 37 def asg @asg_client ||= AutoScaling.new(@asg_name, @region) end
client()
click to toggle source
The Elasticsearch
client object
# File lib/elasticsearch/drain.rb, line 26 def client return @client unless @client.nil? @client = ::Elasticsearch::Client.new( hosts: hosts, retry_on_failure: true, log: true, logger: ::Logger.new('es_client.log', 10, 1_024_000) ) end
cluster()
click to toggle source
Convenience method to access {Elasticsearch::Drain::Cluster#cluster}
@return [Elasticsearch::API::Cluster] Elasticsearch
cluster client
# File lib/elasticsearch/drain.rb, line 49 def cluster @cluster_client ||= Cluster.new(client) end
nodes()
click to toggle source
Convenience method to access {Elasticsearch::Drain::Nodes}
# File lib/elasticsearch/drain.rb, line 42 def nodes @nodes ||= Nodes.new(client, asg) end