Skip to content

Commit 067842d

Browse files
andrewvckarmi
authored andcommitted
[CLIENT] Changed, that the Manticore client is initialized only once
The current implementation makes multiple ES output workers use too many connections, and consequently Logstash failures. Closes #281
1 parent e7c0e92 commit 067842d

File tree

1 file changed

+14
-6
lines changed
  • elasticsearch-transport/lib/elasticsearch/transport/transport/http

1 file changed

+14
-6
lines changed

elasticsearch-transport/lib/elasticsearch/transport/transport/http/manticore.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ module HTTP
4545
class Manticore
4646
include Base
4747

48+
def initialize(arguments={}, &block)
49+
@manticore = build_client(arguments[:options] || {})
50+
super()
51+
end
52+
53+
# Should just be run once at startup
54+
def build_client(options={})
55+
client_options = options[:transport_options] || {}
56+
client_options[:ssl] = options[:ssl] || {}
57+
58+
@manticore = ::Manticore::Client.new(client_options)
59+
end
60+
4861
# Performs the request by invoking {Transport::Base#perform_request} with a block.
4962
#
5063
# @return [Response]
@@ -84,9 +97,6 @@ def __build_connections
8497
@request_options[:headers] = options[:headers]
8598
end
8699

87-
client_options = options[:transport_options] || {}
88-
client_options[:ssl] = options[:ssl] || {}
89-
90100
Connections::Collection.new \
91101
:connections => hosts.map { |host|
92102
host[:protocol] = host[:scheme] || DEFAULT_PROTOCOL
@@ -95,11 +105,9 @@ def __build_connections
95105
host.delete(:user) # auth is not supported here.
96106
host.delete(:password) # use the headers
97107

98-
url = __full_url(host)
99-
100108
Connections::Connection.new \
101109
:host => host,
102-
:connection => ::Manticore::Client.new(client_options)
110+
:connection => @manticore
103111
},
104112
:selector_class => options[:selector_class],
105113
:selector => options[:selector]

0 commit comments

Comments
 (0)