Class: LogStash::Filters::Jdbc::Loader
- Inherits:
-
Validatable
- Object
- Validatable
- LogStash::Filters::Jdbc::Loader
- Includes:
- Util::Loggable
- Defined in:
- lib/logstash/filters/jdbc/loader.rb
Constant Summary collapse
- CONNECTION_ERROR_MSG =
"Remote DB connection error when executing loader Jdbc query"
Instance Attribute Summary collapse
-
#connection_string ⇒ Object
readonly
Returns the value of attribute connection_string.
-
#driver_class ⇒ Object
readonly
Returns the value of attribute driver_class.
-
#driver_library ⇒ Object
readonly
Returns the value of attribute driver_library.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#max_rows ⇒ Object
readonly
Returns the value of attribute max_rows.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#staging_directory ⇒ Object
readonly
Returns the value of attribute staging_directory.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
Methods inherited from Validatable
find_validation_errors, #formatted_errors, #initialize, #valid?
Constructor Details
This class inherits a constructor from LogStash::Filters::Jdbc::Validatable
Instance Attribute Details
#connection_string ⇒ Object (readonly)
Returns the value of attribute connection_string.
14 15 16 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 14 def connection_string @connection_string end |
#driver_class ⇒ Object (readonly)
Returns the value of attribute driver_class.
14 15 16 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 14 def driver_class @driver_class end |
#driver_library ⇒ Object (readonly)
Returns the value of attribute driver_library.
14 15 16 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 14 def driver_library @driver_library end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 13 def id @id end |
#max_rows ⇒ Object (readonly)
Returns the value of attribute max_rows.
13 14 15 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 13 def max_rows @max_rows end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
15 16 17 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 15 def password @password end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
13 14 15 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 13 def query @query end |
#staging_directory ⇒ Object (readonly)
Returns the value of attribute staging_directory.
15 16 17 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 15 def staging_directory @staging_directory end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
13 14 15 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 13 def table @table end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
15 16 17 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 15 def user @user end |
Instance Method Details
#build_remote_db ⇒ Object
17 18 19 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 17 def build_remote_db @remote = ReadOnlyDatabase.create(connection_string, driver_class, driver_library, user, password) end |
#close ⇒ Object
37 38 39 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 37 def close @remote.disconnect(CONNECTION_ERROR_MSG) end |
#fetch ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/logstash/filters/jdbc/loader.rb', line 21 def fetch @remote.connect(CONNECTION_ERROR_MSG) row_count = @remote.count(query) if row_count.zero? logger.warn? && logger.warn("Query returned no results", :lookup_id => @id, :query => query) return @remote.empty_record_set end if row_count > max_rows logger.warn? && logger.warn("Query returned more than max_rows results", :lookup_id => @id, :query => query, :count => row_count, :max_rows => max_rows) return @remote.empty_record_set end @remote.query(query) ensure @remote.disconnect(CONNECTION_ERROR_MSG) end |