public abstract class AbstractJDBCOutput
extends org.thales.punch.libraries.storm.api.BaseProcessingNode
This class uses the storm jdbc connector and Hikari Jdbc Connection Pooling.
Connection to Jdbc database (refer to as datasource in HikariCP terminology) are stored in memory as long as the process is running.
This connection is shared amongst the topology process.
A specific number of Jdbc connection can be maintained alive. Please, refer to HikariCP official documentation for more in depth information.
Here is a list of additional Jdbc bolt that can be implemented easily: https://github.com/brettwooldridge/HikariCP, refer to datasources section.
Grab the datasource class accordingly to the Jdbc on which you want to interact.
HirakiConfigMap.put("dataSourceClassName", "your_db_source_class");
On the other hand, some Jdbc connector are not listed by HirakiCP (no official datasource class), for instance Omnisci.
You will have to construct your own Jdbc String connector. Each url string connector may have their own convention.
Please, refer to the official documentation of the Jdbc you want to work on.
HirakiConfigMap.put("dataSourceClassName", your_constructed_url_string);
For implementing a new Jdbc Insert Bolt, you should create a new class extending the AbstractJDBCBolt class.
Override the methods: execute, cleanup and prepare, if needed.
Don't forget to update your pom.xml by adding the official Jdbc connector you want to add
Modifier and Type | Field and Description |
---|---|
protected List<org.apache.storm.tuple.Tuple> |
ackFail |
protected int |
bulkSize |
static String |
COLUMN_NAME_WRAPPER_CHAR_SETTING
column_name_wrapper_char: This optional setting provides a DB-specific character that will
be used around column names to allow for special characters in column names, like @
|
static String |
COLUMN_NAMES_SETTING
Settings
|
static String |
COLUMN_TYPE_CAST |
static String |
COLUMN_TYPE_FUNCTION |
protected List<String[]> |
columnNames |
protected String |
columnNameWrapper |
protected String |
columnsNamesSeparator |
static String |
CONVERT_BOOLEAN_TO_INT_SETTING
convert_boolean_to_int: if true, then the boolean value will be converted to 0 or 1 integer value at insert
|
protected Boolean |
convertBooleanToInt |
protected String |
database |
protected long |
expirationTimeout |
protected List<Map<String,Object>> |
hikariConfigMaps |
protected List<String> |
hosts |
protected org.thales.punch.libraries.utils.api.RoundRobinIterator<JdbcHandle> |
jdbcHandleIterator |
protected long |
lastUpdateTimestamp |
protected String |
password |
protected String |
poolName |
protected int |
poolSize |
protected int |
queryQueueTime |
protected long |
reconnectionTimeout |
static String |
SOURCE_TUPLE_FIELD_SETTING
source_tuple_field: This optional setting provides the name of an input tuple field that is expected
to contain a map-like object, providing all fields, instead of having many fields in
the storm stream.
|
protected String |
sourceTupleField |
protected String |
table |
protected String |
username |
Modifier | Constructor and Description |
---|---|
protected |
AbstractJDBCOutput(org.thales.punch.libraries.storm.api.NodeSettings config,
String backend) |
Modifier and Type | Method and Description |
---|---|
protected void |
addTupleToQuery(org.apache.storm.tuple.Tuple input)
Add a tuple to INSERT query.
|
void |
cleanup() |
protected void |
failAll() |
protected Object |
formatColumnForAutoCast(Object value) |
protected Object |
formatColumnForFunction(Object value) |
Map<String,Object> |
getComponentConfiguration() |
protected String |
getDefaultColumnNameWrapperChar() |
protected Boolean |
getDefaultConvertBooleanToInt() |
void |
prepare(Map stormConf,
org.apache.storm.task.TopologyContext context,
org.apache.storm.task.OutputCollector collector) |
void |
process(org.apache.storm.tuple.Tuple input) |
public static final String COLUMN_NAMES_SETTING
column_names: This optional setting specifies a list of
public static final String COLUMN_NAME_WRAPPER_CHAR_SETTING
public static final String SOURCE_TUPLE_FIELD_SETTING
public static final String CONVERT_BOOLEAN_TO_INT_SETTING
public static final String COLUMN_TYPE_CAST
public static final String COLUMN_TYPE_FUNCTION
protected final String username
protected final String password
protected final String database
protected final String poolName
protected final String table
protected final int bulkSize
protected final int poolSize
protected final int queryQueueTime
protected final String columnNameWrapper
protected final String columnsNamesSeparator
protected final String sourceTupleField
protected final Boolean convertBooleanToInt
protected final long expirationTimeout
protected long lastUpdateTimestamp
protected final long reconnectionTimeout
protected transient List<org.apache.storm.tuple.Tuple> ackFail
protected transient org.thales.punch.libraries.utils.api.RoundRobinIterator<JdbcHandle> jdbcHandleIterator
protected AbstractJDBCOutput(org.thales.punch.libraries.storm.api.NodeSettings config, String backend) throws org.thales.punch.exceptions.ConfigurationException
org.thales.punch.exceptions.ConfigurationException
public Map<String,Object> getComponentConfiguration()
getComponentConfiguration
in interface org.apache.storm.topology.IComponent
getComponentConfiguration
in class org.thales.punch.libraries.storm.api.BaseProcessingNode
public void prepare(Map stormConf, org.apache.storm.task.TopologyContext context, org.apache.storm.task.OutputCollector collector)
prepare
in interface org.apache.storm.task.IBolt
prepare
in class org.thales.punch.libraries.storm.api.BaseProcessingNode
public void process(org.apache.storm.tuple.Tuple input)
process
in class org.thales.punch.libraries.storm.api.BaseProcessingNode
protected void addTupleToQuery(org.apache.storm.tuple.Tuple input)
input
- tuple to addprotected void failAll()
public void cleanup()
cleanup
in interface org.apache.storm.task.IBolt
cleanup
in class org.thales.punch.libraries.storm.api.BaseProcessingNode
protected String getDefaultColumnNameWrapperChar()
protected Boolean getDefaultConvertBooleanToInt()
Copyright © 2022. All rights reserved.