Class: LogStash::Outputs::ElasticSearch::LicenseChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/elasticsearch/license_checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ LicenseChecker

Returns a new instance of LicenseChecker.



4
5
6
# File 'lib/logstash/outputs/elasticsearch/license_checker.rb', line 4

def initialize(logger)
  @logger = logger
end

Instance Method Details

#appropriate_license?(pool, url) ⇒ Boolean

Figure out if the provided license is appropriate or not The appropriate_license? methods is the method called from LogStash::Outputs::ElasticSearch::HttpClient::Pool#healthcheck!

Parameters:

  • pool
  • url (LogStash::Util::SafeURI)

    ES node URL

Returns:

  • (Boolean)

    true if provided license is deemed appropriate



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/logstash/outputs/elasticsearch/license_checker.rb', line 13

def appropriate_license?(pool, url)
  return true if pool.serverless?

  license = extract_license(pool.get_license(url))
  case license_status(license)
  when 'active'
    true
  when nil
    warn_no_license(url)
    false
  else # 'invalid', 'expired'
    warn_invalid_license(url, license)
    true
  end
end

#extract_license(license) ⇒ Object



32
33
34
# File 'lib/logstash/outputs/elasticsearch/license_checker.rb', line 32

def extract_license(license)
  license.fetch("license", NO_LICENSE)
end

#license_status(license) ⇒ Object



36
37
38
# File 'lib/logstash/outputs/elasticsearch/license_checker.rb', line 36

def license_status(license)
  license.fetch("status", nil)
end