Skip to content

Commit 0e4f82b

Browse files
mvoe oss? and valid_es_license? into mixin
1 parent 79e79b8 commit 0e4f82b

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

lib/logstash/outputs/elasticsearch/http_client/pool.rb

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ def initialize(logger, adapter, initial_urls=[], options={})
7070
@stopping = false
7171
end
7272

73-
def oss?
74-
LogStash::OSS
75-
end
76-
7773
def start
7874
update_initial_urls
7975
start_resurrectionist
@@ -212,7 +208,6 @@ def address_str_to_uri(addr_str)
212208
end
213209
end
214210

215-
216211
def sniff_2x_1x(nodes)
217212
nodes.map do |id,info|
218213
# TODO Make sure this works with shield. Does that listed
@@ -252,13 +247,6 @@ def get_license(url)
252247
LogStash::Json.load(response.body)
253248
end
254249

255-
def valid_es_license?(url)
256-
license = get_license(url)
257-
license.fetch("license", {}).fetch("status", nil) == "active"
258-
rescue => e
259-
false
260-
end
261-
262250
def health_check_request(url)
263251
perform_request_to_url(url, :head, @healthcheck_path)
264252
end
@@ -285,9 +273,9 @@ def healthcheck!
285273
set_new_major_version(major)
286274
end
287275

288-
# defined in license_check.rb
276+
# license_check in mixed in from LogStash::Outputs::ElasticSearchPoolMixin::LicenseChecker
277+
# separately defined in the elasticsearch output and the elasticsearch_data_streams output.
289278
license_check!(url, meta)
290-
291279
end
292280
rescue HostUnreachableError, BadResponseCodeError => e
293281
logger.warn("Attempted to resurrect connection to dead ES instance, but got an error.", url: url.sanitized.to_s, error_type: e.class, error: e.message)
@@ -299,10 +287,6 @@ def stop_resurrectionist
299287
@resurrectionist.join if @resurrectionist
300288
end
301289

302-
def log_license_deprecation_warn(url)
303-
logger.warn("DEPRECATION WARNING: Connecting to an OSS distribution of Elasticsearch using the default distribution of Logstash will stop working in Logstash 8.0.0. Please upgrade to the default distribution of Elasticsearch, or use the OSS distribution of Logstash", :url => url.sanitized.to_s)
304-
end
305-
306290
def resurrectionist_alive?
307291
@resurrectionist ? @resurrectionist.alive? : nil
308292
end

lib/logstash/outputs/elasticsearch/license_check.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ module ElasticSearchPoolMixin
44
module LicenseChecker
55

66
# This mixin is used to externalize the license checking behaviour of the LogStash::Outputs::ElasticSearch::HttpClient::Pool class.
7+
# This mixin used the following Pool methods: get_license, logger. Make sure these are defined in the license_check_mixin_spec.rb
78

89
# Perform a license check
10+
# The license_check! methods is the method called from within the Pool class
911
# @param url [LogStash::Util::SafeURI]
1012
# @param meta [Hash]
1113
def license_check!(url, meta)
@@ -23,6 +25,21 @@ def license_check!(url, meta)
2325
meta[:state] = :alive
2426
end
2527
end
28+
29+
def oss?
30+
LogStash::OSS
31+
end
32+
33+
def valid_es_license?(url)
34+
license = get_license(url)
35+
license.fetch("license", {}).fetch("status", nil) == "active"
36+
rescue => e
37+
false
38+
end
39+
40+
def log_license_deprecation_warn(url)
41+
logger.warn("DEPRECATION WARNING: Connecting to an OSS distribution of Elasticsearch using the default distribution of Logstash will stop working in Logstash 8.0.0. Please upgrade to the default distribution of Elasticsearch, or use the OSS distribution of Logstash", :url => url.sanitized.to_s)
42+
end
2643
end
2744
end
2845
end

0 commit comments

Comments
 (0)