Module: LogStash::PluginMixins::JdbcStreaming

Included in:
Filters::JdbcStreaming
Defined in:
lib/logstash/plugin_mixins/jdbc_streaming.rb,
lib/logstash/plugin_mixins/jdbc_streaming/cache_payload.rb,
lib/logstash/plugin_mixins/jdbc_streaming/parameter_handler.rb,
lib/logstash/plugin_mixins/jdbc_streaming/statement_handler.rb

Defined Under Namespace

Classes: CachePayload, ConstantParameter, FieldParameter, InterpolatedParameter, NoCache, NormalStatementHandler, ParameterHandler, PreparedStatementHandler, RowCache, StatementHandler

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

This method is called when someone includes this module



26
27
28
29
30
# File 'lib/logstash/plugin_mixins/jdbc_streaming.rb', line 26

def self.included(base)
  # Add these methods to the 'base' given.
  base.extend(self)
  base.setup_jdbc_config
end

Instance Method Details

#prepare_jdbc_connectionObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/logstash/plugin_mixins/jdbc_streaming.rb', line 59

def prepare_jdbc_connection
  load_driver

  @database = Sequel.connect(@jdbc_connection_string, complete_sequel_opts)
  if @jdbc_validate_connection
    @database.extension(:connection_validator)
    @database.pool.connection_validation_timeout = @jdbc_validation_timeout
  end
  begin
    @database.test_connection
  rescue Sequel::DatabaseConnectionError => e
    #TODO return false and let the plugin raise a LogStash::ConfigurationError
    raise e
  end
end

#setup_jdbc_configObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/logstash/plugin_mixins/jdbc_streaming.rb', line 33

def setup_jdbc_config
  # JDBC driver library path to third party driver library.
  config :jdbc_driver_library, :validate => :path

  # JDBC driver class to load, for example "oracle.jdbc.OracleDriver" or "org.apache.derby.jdbc.ClientDriver"
  config :jdbc_driver_class, :validate => :string, :required => true

  # JDBC connection string
  config :jdbc_connection_string, :validate => :string, :required => true

  # JDBC user
  config :jdbc_user, :validate => :string

  # JDBC password
  config :jdbc_password, :validate => :password

  # Connection pool configuration.
  # Validate connection before use.
  config :jdbc_validate_connection, :validate => :boolean, :default => false

  # Connection pool configuration.
  # How often to validate a connection (in seconds)
  config :jdbc_validation_timeout, :validate => :number, :default => 3600
end