Class: Elasticsearch::Drain
- Inherits:
-
Object
- Object
- Elasticsearch::Drain
- Defined in:
- lib/elasticsearch/drain.rb,
lib/elasticsearch/drain/cli.rb,
lib/elasticsearch/drain/base.rb,
lib/elasticsearch/drain/node.rb,
lib/elasticsearch/drain/util.rb,
lib/elasticsearch/drain/nodes.rb,
lib/elasticsearch/drain/cluster.rb,
lib/elasticsearch/drain/version.rb,
lib/elasticsearch/drain/autoscaling.rb
Defined Under Namespace
Modules: Errors, Util Classes: AutoScaling, Base, CLI, Cluster, Node, Nodes
Constant Summary collapse
- VERSION =
IO.read(File.('../../../../VERSION', __FILE__)) rescue '0.0.1'
Instance Attribute Summary collapse
-
#hosts ⇒ Object
readonly
The Elasticsearch hosts to connect to.
-
#region ⇒ Object
readonly
EC2 Region.
Instance Method Summary collapse
- #active_nodes_in_asg ⇒ Object
-
#asg ⇒ Object
EC2 AutoScaling Client.
-
#client ⇒ Object
The Elasticsearch client object.
-
#cluster ⇒ Elasticsearch::API::Cluster
Convenience method to access Cluster#cluster.
-
#initialize(hosts = 'localhost:9200', asg = nil, region = nil) ⇒ Elasticsearch::Transport::Client
constructor
Sets up the Elasticsearch client.
-
#nodes ⇒ Object
Convenience method to access Nodes.
Constructor Details
#initialize(hosts = 'localhost:9200', asg = nil, region = nil) ⇒ Elasticsearch::Transport::Client
Sets up the Elasticsearch client
19 20 21 22 23 |
# File 'lib/elasticsearch/drain.rb', line 19 def initialize(hosts = 'localhost:9200', asg = nil, region = nil) @hosts = hosts @region = region @asg_name = asg end |
Instance Attribute Details
#hosts ⇒ Object (readonly)
The Elasticsearch hosts to connect to
8 9 10 |
# File 'lib/elasticsearch/drain.rb', line 8 def hosts @hosts end |
#region ⇒ Object (readonly)
EC2 Region
12 13 14 |
# File 'lib/elasticsearch/drain.rb', line 12 def region @region end |
Instance Method Details
#active_nodes_in_asg ⇒ Object
53 54 55 56 |
# File 'lib/elasticsearch/drain.rb', line 53 def active_nodes_in_asg instances = asg.instances nodes.filter_nodes(instances, true) end |
#asg ⇒ Object
EC2 AutoScaling Client
37 38 39 |
# File 'lib/elasticsearch/drain.rb', line 37 def asg @asg_client ||= AutoScaling.new(@asg_name, @region) end |
#client ⇒ Object
The Elasticsearch client object
26 27 28 29 30 31 32 33 34 |
# 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 ⇒ Elasticsearch::API::Cluster
Convenience method to access Elasticsearch::Drain::Cluster#cluster
49 50 51 |
# File 'lib/elasticsearch/drain.rb', line 49 def cluster @cluster_client ||= Cluster.new(client) end |