Sha256: 475e37a9bc8654c34e49bbdd9422d98dc58bf13c9e8293033a0258f7091c12c9

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

# SPDX-License-Identifier: Apache-2.0
#
#  The OpenSearch Contributors require contributions made to
#  this file be licensed under the Apache-2.0 license or a
#  compatible open source license.
#
#  Modifications Copyright OpenSearch Contributors. See
#  GitHub history for details.
#
module LogStash; module Outputs; class OpenSearch
  class DistributionChecker

    def initialize(logger)
      @logger = logger
    end

    # Checks whether connecting cluster is one of supported distribution or not
    # @param pool
    # @param url [LogStash::Util::SafeURI] OpenSearch node URL
    # @param major_version OpenSearch major version number
    # @return [Boolean] true if supported
    def is_supported?(pool, url, major_version)
      distribution = get_distribution(pool, url)
      case distribution
      when 'opensearch'
        return true
      when 'oss'
        if major_version == 7
          return true
        end
      end
      log_not_supported(url, major_version, distribution)
      false
    end

    def get_distribution(pool, url)
      pool.get_distribution(url)
    end

    def log_not_supported(url, major_version, distribution)
      @logger.error("Could not connect to cluster", url: url.sanitized.to_s, distribution: distribution, major_version: major_version)
    end
  end
end; end; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-output-opensearch-1.0.0-java lib/logstash/outputs/opensearch/distribution_checker.rb