Class: LogStash::Filters::JdbcStreaming
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::JdbcStreaming
- Includes:
- PluginMixins::JdbcStreaming
- Defined in:
- lib/logstash/filters/jdbc_streaming.rb
Instance Attribute Summary collapse
-
#prepared_statement_constant_warned ⇒ Object
readonly
for test verification, remove when warning is deprecated and removed.
Instance Method Summary collapse
Methods included from PluginMixins::JdbcStreaming
included, #prepare_jdbc_connection, #setup_jdbc_config
Instance Attribute Details
#prepared_statement_constant_warned ⇒ Object (readonly)
for test verification, remove when warning is deprecated and removed
98 99 100 |
# File 'lib/logstash/filters/jdbc_streaming.rb', line 98 def prepared_statement_constant_warned @prepared_statement_constant_warned end |
Instance Method Details
#close ⇒ Object
138 139 140 141 142 |
# File 'lib/logstash/filters/jdbc_streaming.rb', line 138 def close @database.disconnect rescue => e logger.warn("Exception caught when attempting to close filter.", :exception => e., :backtrace => e.backtrace) end |
#filter(event) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/logstash/filters/jdbc_streaming.rb', line 123 def filter(event) result = @statement_handler.cache_lookup(@database, event) # should return a CachePayload instance if result.failed? tag_failure(event) end if result.empty? tag_default(event) process_event(event, @default_array) else process_event(event, result.payload) end end |
#register ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/logstash/filters/jdbc_streaming.rb', line 103 def register if @use_prepared_statements validation_errors = validate_prepared_statement_mode unless validation_errors.empty? raise(LogStash::ConfigurationError, "Prepared Statement Mode validation errors: " + validation_errors.join(", ")) end else # symbolise and wrap value in parameter handler unless @parameters.values.all?{|v| v.is_a?(PluginMixins::JdbcStreaming::ParameterHandler)} @parameters = parameters.inject({}) do |hash,(k,value)| hash[k.to_sym] = PluginMixins::JdbcStreaming::ParameterHandler.build_parameter_handler(value) hash end end end @statement_handler = LogStash::PluginMixins::JdbcStreaming::StatementHandler.build_statement_handler(self) prepare_jdbc_connection end |