org.apache.storm.jdbc.mapper.JdbcMapper Java Examples

The following examples show how to use org.apache.storm.jdbc.mapper.JdbcMapper. 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 vote down vote up
@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 vote down vote up
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: StreamlineJdbcInsertBolt.java    From streamline with Apache License 2.0 4 votes vote down vote up
public StreamlineJdbcInsertBolt(ConnectionProvider connectionProvider, JdbcMapper jdbcMapper) {
    super(connectionProvider, jdbcMapper);
}