Sha256: a2e52b9e794adc903c6cb9b6cf61b22b46c9a59f0606bcf5b3c5e176e06cdfbc

Contents?: true

Size: 1.88 KB

Versions: 46

Compression:

Stored size: 1.88 KB

Contents

# encoding: utf-8
require_relative "basic_database"

module LogStash module Filters module Jdbc
  class ReadOnlyDatabase < BasicDatabase

    def count(statement)
      result = 0
      debug_log_messages = ["Lookup query count is zero"]
      begin
        # its the responsibility of the caller to manage the connections see Loader
        if connected?
          result = @db[statement].count
        else
          debug_log_messages.concat("and there is no connection to the remote db at this time")
        end
      rescue ::Sequel::Error => err
        # a fatal issue
        msg = "Exception occurred when executing loader Jdbc query count"
        logger.error(msg, :exception => err.message, :backtrace => err.backtrace.take(8))
        raise wrap_error(LookupJdbcException, err, msg)
      end
      logger.debug(debug_log_messages.join(' ')) if result.zero?
      result
    end

    def query(statement)
      result = empty_record_set
      debug_log_messages = ["Lookup query results are empty"]
      begin
        # its the responsibility of the caller to manage the connections see Loader
        if connected?
          result = @db[statement].all
        else
          debug_log_messages.concat("and there is no connection to the remote db at this time")
        end
      rescue ::Sequel::Error => err
        # a fatal issue
        msg = "Exception occurred when executing loader Jdbc query"
        logger.error(msg, :exception => err.message, :backtrace => err.backtrace.take(8))
        raise wrap_error(LookupJdbcException, err, msg)
      end
      logger.debug(debug_log_messages.join(' ')) if result.empty?
      result
    end

    def post_create(connection_string, driver_class, driver_library, user, password)
      verify_connection(connection_string, driver_class, driver_library, user, password)
    end

    private

    def post_initialize()
      super
    end
  end
end end end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
logstash-integration-jdbc-5.4.9 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.4.8 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.4.7 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.4.6 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.4.5 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.4.4 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.4.3 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.4.2 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.4.1 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.4.0 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.3.0 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.2.6 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.2.5 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.2.4 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.2.3 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.2.2 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.2.1 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.2.0 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.1.10 lib/logstash/filters/jdbc/read_only_database.rb
logstash-integration-jdbc-5.1.8 lib/logstash/filters/jdbc/read_only_database.rb