|
16 | 16 | # under the License.
|
17 | 17 |
|
18 | 18 | require "elasticsearch"
|
19 |
| -require "elasticsearch/transport/transport/http/manticore" |
| 19 | +require "elastic/transport/transport/http/manticore" |
20 | 20 | require 'logstash/util/manticore_ssl_config_helper'
|
21 | 21 | require 'logstash/util/password'
|
22 | 22 |
|
23 | 23 | module LogStash class ElasticsearchClient
|
24 | 24 | include LogStash::Util::Loggable
|
25 | 25 |
|
26 | 26 | class Response
|
27 |
| - # duplicated here from Elasticsearch::Transport::Transport::Response |
| 27 | + # duplicated here from Elastic::Transport::Transport::Response |
28 | 28 | # to create a normalised response across different client IMPL
|
29 | 29 | attr_reader :status, :body, :headers
|
30 | 30 |
|
@@ -65,8 +65,13 @@ def initialize(settings, logger)
|
65 | 65 | def can_connect?
|
66 | 66 | begin
|
67 | 67 | head(SecureRandom.hex(32).prepend('_'))
|
68 |
| - rescue Elasticsearch::Transport::Transport::Errors::BadRequest |
| 68 | + rescue Elastic::Transport::Transport::Errors::BadRequest |
69 | 69 | true
|
| 70 | + rescue Elastic::Transport::Transport::Errors::Unauthorized |
| 71 | + true |
| 72 | + rescue Exception => e |
| 73 | + return true if e.message.include?('Connection refused') |
| 74 | + raise e |
70 | 75 | rescue Manticore::SocketException
|
71 | 76 | false
|
72 | 77 | end
|
@@ -116,7 +121,7 @@ def normalize_response(response)
|
116 | 121 |
|
117 | 122 | def client_args
|
118 | 123 | {
|
119 |
| - :transport_class => Elasticsearch::Transport::Transport::HTTP::Manticore, |
| 124 | + :transport_class => Elastic::Transport::Transport::HTTP::Manticore, |
120 | 125 | :hosts => [*unpack_hosts],
|
121 | 126 | # :logger => @logger, # silence the client logging
|
122 | 127 | }
|
|
0 commit comments