org.apache.storm.jdbc.common.ConnectionProvider Java Examples
The following examples show how to use
org.apache.storm.jdbc.common.ConnectionProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WordCountToMySQLBoltBuilder.java From storm_spring_boot_demo with MIT License | 6 votes |
@Bean("wordCountToMySQLBolt") public JdbcInsertBolt buildBolt() { super.setId("wordCountToMySQLBolt"); Map hikariConfigMap = Maps.newHashMap(); hikariConfigMap.put("dataSourceClassName", mySQLProps.getDataSourceClassName()); hikariConfigMap.put("dataSource.url", mySQLProps.getDataSourceUrl()); hikariConfigMap.put("dataSource.user", mySQLProps.getDataSourceUser()); hikariConfigMap.put("dataSource.password", mySQLProps.getDataSourcePassword()); ConnectionProvider connectionProvider = new HikariCPConnectionProvider(hikariConfigMap); List<Column> columnSchema = Lists.newArrayList( new Column("targetDate", Types.DATE), new Column("word", java.sql.Types.VARCHAR), new Column("count", Types.BIGINT), new Column("count_0", Types.BIGINT) ); // JdbcMapper simpleJdbcMapper = new SimpleJdbcMapper(tableName, connectionProvider); JdbcMapper simpleJdbcMapper = new SimpleJdbcMapper(columnSchema); JdbcInsertBolt insertBolt = new JdbcInsertBolt(connectionProvider, simpleJdbcMapper) .withInsertQuery(insertQuery) .withQueryTimeoutSecs(queryTimeoutSecs); return insertBolt; }
Example #2
Source File: LocalWordCountJDBCStormTopology.java From 163-bigdate-note with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) { //根据Spout和Bolt构建TopologyBuilder TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("DataSourceSpout", new DataSourceSpout()); builder.setBolt("SplitBolt", new SplitBolt()).shuffleGrouping("DataSourceSpout"); builder.setBolt("CountBolt", new CountBolt()).shuffleGrouping("SplitBolt"); Map hikariConfigMap = Maps.newHashMap(); hikariConfigMap.put("dataSourceClassName","com.mysql.jdbc.jdbc2.optional.MysqlDataSource"); hikariConfigMap.put("dataSource.url", "jdbc:mysql://192.168.60.11/storm"); hikariConfigMap.put("dataSource.user","root"); hikariConfigMap.put("dataSource.password","123"); ConnectionProvider connectionProvider = new HikariCPConnectionProvider(hikariConfigMap); String tableName = "wc"; JdbcMapper simpleJdbcMapper = new SimpleJdbcMapper(tableName, connectionProvider); JdbcInsertBolt userPersistanceBolt = new JdbcInsertBolt(connectionProvider, simpleJdbcMapper) .withTableName(tableName) .withQueryTimeoutSecs(30); builder.setBolt("JdbcInsertBolt", userPersistanceBolt).shuffleGrouping("CountBolt"); //创建本地集群 LocalCluster cluster = new LocalCluster(); cluster.submitTopology("LocalWordCountRedisStormTopology", new Config(), builder.createTopology()); }
Example #3
Source File: StreamlineJdbcMapper.java From streamline with Apache License 2.0 | 5 votes |
public StreamlineJdbcMapper(String tableName, ConnectionProvider connectionProvider, List<String> fields) { this.tableName = tableName; this.connectionProvider = connectionProvider; this.fields = fields; LOG.info("JDBC Mapper initialized with tableName: {}, connectionProvider: {}, fields: {}", tableName, connectionProvider, fields); }
Example #4
Source File: StreamlineJdbcInsertBolt.java From streamline with Apache License 2.0 | 4 votes |
public StreamlineJdbcInsertBolt(ConnectionProvider connectionProvider, JdbcMapper jdbcMapper) { super(connectionProvider, jdbcMapper); }