public class SimpleRiverSource<RC extends SimpleRiverContext> extends Object implements RiverSource<RC>
Modifier and Type | Field and Description |
---|---|
protected Calendar |
calendar |
protected RC |
context |
protected org.elasticsearch.common.joda.time.DateTimeZone |
dateTimeZone |
protected Locale |
locale |
protected String |
password |
protected Connection |
readConnection |
protected boolean |
suspended |
protected TimeZone |
timezone |
protected String |
url |
protected String |
user |
protected Connection |
writeConnection |
Constructor and Description |
---|
SimpleRiverSource() |
Modifier and Type | Method and Description |
---|---|
void |
afterFetch()
Executed after fetch() has been executed or threw an exception.
|
void |
afterRows(ResultSet results,
KeyValueStreamListener listener)
Executed after all rows have been fetched from result set
|
void |
afterRows(SQLCommand command,
ResultSet results,
KeyValueStreamListener listener)
After the rows keys and values, let the listener know about the end of
the result set.
|
void |
beforeFetch()
Executed before fetch() is executed
|
void |
beforeRows(ResultSet results,
KeyValueStreamListener listener)
Executed before rows are fetched from result set
|
void |
beforeRows(SQLCommand command,
ResultSet results,
KeyValueStreamListener listener)
Before rows are read, let the KeyValueStreamListener know about the keys.
|
SimpleRiverSource |
bind(PreparedStatement statement,
List<Object> values)
Bind values to prepared statement
|
SimpleRiverSource |
close(ResultSet result)
Close result set
|
SimpleRiverSource |
close(Statement statement)
Close statement
|
SimpleRiverSource |
closeReading()
Close read connection
|
SimpleRiverSource |
closeWriting()
Close read connection
|
ResultSet |
executeQuery(PreparedStatement statement)
Execute prepared query statement
|
ResultSet |
executeQuery(Statement statement,
String sql)
Execute query statement
|
RiverSource |
executeUpdate(PreparedStatement statement)
Execute prepared update statement
|
RiverSource |
executeUpdate(Statement statement,
String sql)
Execute prepared update statement
|
void |
fetch()
River fetch.
|
Connection |
getConnectionForReading()
Get JDBC connection for reading
|
Connection |
getConnectionForWriting()
Get JDBC connection for writing.
|
Locale |
getLocale()
Get the current locale
|
TimeZone |
getTimeZone()
Get the current timezone of this river source for the JDBC setTimestamp() call
|
String |
getUrl() |
protected void |
merge(SQLCommand command,
ResultSet results,
KeyValueStreamListener listener)
Merge key/values from JDBC result set
|
SimpleRiverSource<RC> |
newInstance()
Create new river source instance
|
boolean |
nextRow(ResultSet results,
KeyValueStreamListener listener)
Executed when next row is fetched from result set
|
boolean |
nextRow(SQLCommand command,
ResultSet results,
KeyValueStreamListener listener)
Get next row and prepare the values for processing.
|
Object |
parseType(ResultSet result,
Integer i,
int type,
Locale locale)
Parse of value of result set
|
PreparedStatement |
prepareQuery(String sql)
Prepare a query statement
|
PreparedStatement |
prepareUpdate(String sql)
Prepare an update statement
|
SimpleRiverSource |
register(CallableStatement statement,
Map<String,Object> values)
Register variables in callable statement
|
void |
resume()
Resume river source
|
SimpleRiverSource |
setLocale(Locale locale)
Set the locale for JDBC
|
SimpleRiverSource |
setPassword(String password)
Set the password authentication
|
SimpleRiverSource |
setRiverContext(RC context)
Set the river context
|
SimpleRiverSource |
setTimeZone(TimeZone timezone)
Set the timezone for JDBC setTimestamp() calls with calendar object.
|
SimpleRiverSource |
setUrl(String url)
Set JDBC connection URL
|
SimpleRiverSource |
setUser(String user)
Set the user authentication
|
void |
shutdown()
Shutdown source
|
String |
strategy()
The strategy this river source supports.
|
void |
suspend()
Suspend river source
|
protected RC extends SimpleRiverContext context
protected Connection readConnection
protected Connection writeConnection
protected org.elasticsearch.common.joda.time.DateTimeZone dateTimeZone
protected volatile boolean suspended
public SimpleRiverSource()
public String strategy()
RiverSource
strategy
in interface RiverSource<RC extends SimpleRiverContext>
public SimpleRiverSource<RC> newInstance()
RiverSource
newInstance
in interface RiverSource<RC extends SimpleRiverContext>
public SimpleRiverSource setRiverContext(RC context)
RiverSource
setRiverContext
in interface RiverSource<RC extends SimpleRiverContext>
context
- the contextpublic SimpleRiverSource setUrl(String url)
RiverSource
setUrl
in interface RiverSource<RC extends SimpleRiverContext>
url
- the JDBC connection URLpublic SimpleRiverSource setUser(String user)
RiverSource
setUser
in interface RiverSource<RC extends SimpleRiverContext>
user
- the userpublic SimpleRiverSource setPassword(String password)
RiverSource
setPassword
in interface RiverSource<RC extends SimpleRiverContext>
password
- the passwordpublic SimpleRiverSource setLocale(Locale locale)
RiverSource
setLocale
in interface RiverSource<RC extends SimpleRiverContext>
locale
- localepublic Locale getLocale()
RiverSource
getLocale
in interface RiverSource<RC extends SimpleRiverContext>
public SimpleRiverSource setTimeZone(TimeZone timezone)
RiverSource
setTimeZone
in interface RiverSource<RC extends SimpleRiverContext>
timezone
- the time zonepublic TimeZone getTimeZone()
RiverSource
getTimeZone
in interface RiverSource<RC extends SimpleRiverContext>
public void suspend()
RiverSource
suspend
in interface RiverSource<RC extends SimpleRiverContext>
public void resume()
RiverSource
resume
in interface RiverSource<RC extends SimpleRiverContext>
public Connection getConnectionForReading() throws SQLException
getConnectionForReading
in interface RiverSource<RC extends SimpleRiverContext>
SQLException
- when SQL execution gives an errorpublic Connection getConnectionForWriting() throws SQLException
getConnectionForWriting
in interface RiverSource<RC extends SimpleRiverContext>
SQLException
- when SQL execution gives an errorpublic void beforeFetch() throws Exception
RiverSource
beforeFetch
in interface RiverSource<RC extends SimpleRiverContext>
Exception
public void fetch() throws SQLException, IOException
fetch
in interface RiverSource<RC extends SimpleRiverContext>
SQLException
- when SQL execution gives an errorIOException
- when input/output error occurspublic void afterFetch() throws Exception
RiverSource
afterFetch
in interface RiverSource<RC extends SimpleRiverContext>
Exception
public void shutdown()
RiverSource
shutdown
in interface RiverSource<RC extends SimpleRiverContext>
protected void merge(SQLCommand command, ResultSet results, KeyValueStreamListener listener) throws SQLException, IOException, ParseException
results
- result setlistener
- the value listenerSQLException
- when SQL execution gives an errorIOException
- when input/output error occursParseException
public PreparedStatement prepareQuery(String sql) throws SQLException
prepareQuery
in interface RiverSource<RC extends SimpleRiverContext>
sql
- the SQL statementSQLException
- when SQL execution gives an errorpublic PreparedStatement prepareUpdate(String sql) throws SQLException
prepareUpdate
in interface RiverSource<RC extends SimpleRiverContext>
sql
- the SQL statementSQLException
- when SQL execution gives an errorpublic SimpleRiverSource bind(PreparedStatement statement, List<Object> values) throws SQLException
bind
in interface RiverSource<RC extends SimpleRiverContext>
statement
- the prepared statementvalues
- the values to bindSQLException
- when SQL execution gives an errorpublic SimpleRiverSource register(CallableStatement statement, Map<String,Object> values) throws SQLException
register
in interface RiverSource<RC extends SimpleRiverContext>
statement
- callable statementvalues
- valuesSQLException
- when SQL execution gives an errorpublic ResultSet executeQuery(PreparedStatement statement) throws SQLException
executeQuery
in interface RiverSource<RC extends SimpleRiverContext>
statement
- the prepared statementSQLException
- when SQL execution gives an errorpublic ResultSet executeQuery(Statement statement, String sql) throws SQLException
executeQuery
in interface RiverSource<RC extends SimpleRiverContext>
statement
- the statementsql
- the SQLSQLException
- when SQL execution gives an errorpublic RiverSource executeUpdate(PreparedStatement statement) throws SQLException
executeUpdate
in interface RiverSource<RC extends SimpleRiverContext>
statement
- the prepared statementSQLException
- when SQL execution gives an errorpublic RiverSource executeUpdate(Statement statement, String sql) throws SQLException
executeUpdate
in interface RiverSource<RC extends SimpleRiverContext>
statement
- the prepared statementsql
- SQL querySQLException
- when SQL execution gives an errorpublic void beforeRows(ResultSet results, KeyValueStreamListener listener) throws SQLException, IOException
RiverSource
beforeRows
in interface RiverSource<RC extends SimpleRiverContext>
results
- the result setlistener
- a result set listener or nullSQLException
IOException
public void beforeRows(SQLCommand command, ResultSet results, KeyValueStreamListener listener) throws SQLException, IOException
beforeRows
in interface RiverSource<RC extends SimpleRiverContext>
command
- the SQL command that created this result setresults
- the result setlistener
- the key/value stream listenerSQLException
- when SQL execution gives an errorIOException
- when input/output error occurspublic boolean nextRow(ResultSet results, KeyValueStreamListener listener) throws SQLException, IOException
RiverSource
nextRow
in interface RiverSource<RC extends SimpleRiverContext>
results
- the result setlistener
- a result set listener or nullSQLException
IOException
public boolean nextRow(SQLCommand command, ResultSet results, KeyValueStreamListener listener) throws SQLException, IOException
nextRow
in interface RiverSource<RC extends SimpleRiverContext>
command
- the SQL command that created this result setresults
- the result setlistener
- the listenerSQLException
- when SQL execution gives an errorIOException
- when input/output error occurspublic void afterRows(ResultSet results, KeyValueStreamListener listener) throws SQLException, IOException
RiverSource
afterRows
in interface RiverSource<RC extends SimpleRiverContext>
results
- the result setlistener
- a result set listener or nullSQLException
IOException
public void afterRows(SQLCommand command, ResultSet results, KeyValueStreamListener listener) throws SQLException, IOException
afterRows
in interface RiverSource<RC extends SimpleRiverContext>
command
- the SQL command that created this result setresults
- the result setlistener
- the key/value stream listenerSQLException
- when SQL execution gives an errorIOException
- when input/output error occurspublic SimpleRiverSource close(ResultSet result) throws SQLException
close
in interface RiverSource<RC extends SimpleRiverContext>
result
- the result set to be closed or nullSQLException
- when SQL execution gives an errorpublic SimpleRiverSource close(Statement statement) throws SQLException
close
in interface RiverSource<RC extends SimpleRiverContext>
statement
- the statement to be closed or nullSQLException
- when SQL execution gives an errorpublic SimpleRiverSource closeReading()
closeReading
in interface RiverSource<RC extends SimpleRiverContext>
public SimpleRiverSource closeWriting()
closeWriting
in interface RiverSource<RC extends SimpleRiverContext>
public Object parseType(ResultSet result, Integer i, int type, Locale locale) throws SQLException, IOException, ParseException
parseType
in interface RiverSource<RC extends SimpleRiverContext>
result
- the result seti
- the offset in the result settype
- the JDBC typelocale
- the locale to use for parsingSQLException
- when SQL execution gives an errorIOException
- when input/output error occursParseException
- if number format could not be parsedelasticsearch-river-jdbc