Search in sources :

Example 6 with TargetResName

use of com.qlangtech.tis.coredefine.module.action.TargetResName in project plugins by qlangtech.

the class FlinkCDCMysqlSourceFunction method start.

@Override
public JobExecutionResult start(TargetResName dataxName, IDataxReader dataSource, List<ISelectedTab> tabs, IDataxProcessor dataXProcessor) throws MQConsumeException {
    try {
        // TabColIndexer colIndexer = new TabColIndexer(tabs);
        // TISDeserializationSchema deserializationSchema
        // = new TISDeserializationSchema(new MySQLSourceValConvert(colIndexer));
        TISDeserializationSchema deserializationSchema = new TISDeserializationSchema();
        BasicDataXRdbmsReader rdbmsReader = (BasicDataXRdbmsReader) dataSource;
        BasicDataSourceFactory dsFactory = (BasicDataSourceFactory) rdbmsReader.getDataSourceFactory();
        SourceChannel sourceChannel = new SourceChannel(SourceChannel.getSourceFunction(dsFactory, tabs, (dbHost, dbs, tbs, debeziumProperties) -> {
            DateTimeConverter.setDatetimeConverters(MySqlDateTimeConverter.class.getName(), debeziumProperties);
            String[] databases = dbs.toArray(new String[dbs.size()]);
            return Collections.singletonList(new ReaderSource(dbHost + ":" + dsFactory.port + ":" + dbs.stream().collect(Collectors.joining("_")), MySqlSource.<DTO>builder().hostname(dbHost).port(dsFactory.port).databaseList(// monitor all tables under inventory database
            databases).tableList(tbs.toArray(new String[tbs.size()])).serverTimeZone(BasicDataSourceFactory.DEFAULT_SERVER_TIME_ZONE.getId()).username(dsFactory.getUserName()).password(dsFactory.getPassword()).startupOptions(sourceFactory.getStartupOptions()).debeziumProperties(debeziumProperties).deserializer(// converts SourceRecord to JSON String
            deserializationSchema).build()));
        }));
        for (ISelectedTab tab : tabs) {
            sourceChannel.addFocusTab(tab.getName());
        }
        return (JobExecutionResult) getConsumerHandle().consume(dataxName, sourceChannel, dataXProcessor);
    } catch (Exception e) {
        throw new MQConsumeException(e.getMessage(), e);
    }
}
Also used : MQConsumeException(com.qlangtech.tis.async.message.client.consumer.MQConsumeException) DateTimeConverter(com.qlangtech.plugins.incr.flink.cdc.valconvert.DateTimeConverter) IConsumerHandle(com.qlangtech.tis.async.message.client.consumer.IConsumerHandle) TargetResName(com.qlangtech.tis.coredefine.module.action.TargetResName) BasicDataXRdbmsReader(com.qlangtech.tis.plugin.datax.common.BasicDataXRdbmsReader) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) DTO(com.qlangtech.tis.realtime.transfer.DTO) TISDeserializationSchema(com.qlangtech.plugins.incr.flink.cdc.TISDeserializationSchema) Collectors(java.util.stream.Collectors) BasicDataSourceFactory(com.qlangtech.tis.plugin.ds.BasicDataSourceFactory) SourceChannel(com.qlangtech.plugins.incr.flink.cdc.SourceChannel) ReaderSource(com.qlangtech.tis.realtime.ReaderSource) JobExecutionResult(org.apache.flink.api.common.JobExecutionResult) List(java.util.List) IDataxReader(com.qlangtech.tis.datax.IDataxReader) IAsyncMsgDeserialize(com.qlangtech.tis.async.message.client.consumer.IAsyncMsgDeserialize) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) IMQListener(com.qlangtech.tis.async.message.client.consumer.IMQListener) MySqlSource(com.ververica.cdc.connectors.mysql.MySqlSource) Collections(java.util.Collections) JobExecutionResult(org.apache.flink.api.common.JobExecutionResult) TISDeserializationSchema(com.qlangtech.plugins.incr.flink.cdc.TISDeserializationSchema) BasicDataSourceFactory(com.qlangtech.tis.plugin.ds.BasicDataSourceFactory) MQConsumeException(com.qlangtech.tis.async.message.client.consumer.MQConsumeException) SourceChannel(com.qlangtech.plugins.incr.flink.cdc.SourceChannel) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) BasicDataXRdbmsReader(com.qlangtech.tis.plugin.datax.common.BasicDataXRdbmsReader) ReaderSource(com.qlangtech.tis.realtime.ReaderSource) DTO(com.qlangtech.tis.realtime.transfer.DTO) MQConsumeException(com.qlangtech.tis.async.message.client.consumer.MQConsumeException)

Example 7 with TargetResName

use of com.qlangtech.tis.coredefine.module.action.TargetResName in project plugins by qlangtech.

the class TestFlinkCDCMySQLSourceFactory method testBinlogConsumeWithDataStreamRegisterTable.

@Test
public void testBinlogConsumeWithDataStreamRegisterTable() throws Exception {
    FlinkCDCMySQLSourceFactory mysqlCDCFactory = new FlinkCDCMySQLSourceFactory();
    mysqlCDCFactory.startupOptions = "latest";
    final String tabName = "base";
    CUDCDCTestSuit cdcTestSuit = new CUDCDCTestSuit() {

        @Override
        protected BasicDataSourceFactory createDataSourceFactory(TargetResName dataxName) {
            return createMySqlDataSourceFactory(dataxName);
        }

        @Override
        protected String getColEscape() {
            return "`";
        }

        @Override
        protected IResultRows createConsumerHandle(String tabName) {
            return new TestTableRegisterFlinkSourceHandle(tabName, cols);
        }
    };
    cdcTestSuit.startTest(mysqlCDCFactory, tabName);
}
Also used : TargetResName(com.qlangtech.tis.coredefine.module.action.TargetResName) TestTableRegisterFlinkSourceHandle(com.qlangtech.plugins.incr.flink.cdc.source.TestTableRegisterFlinkSourceHandle) CUDCDCTestSuit(com.qlangtech.plugins.incr.flink.cdc.CUDCDCTestSuit) Test(org.junit.Test)

Example 8 with TargetResName

use of com.qlangtech.tis.coredefine.module.action.TargetResName in project plugins by qlangtech.

the class TestFlinkCDCMySQLSourceFactory method testBinlogConsume.

@Test
public void testBinlogConsume() throws Exception {
    FlinkCDCMySQLSourceFactory mysqlCDCFactory = new FlinkCDCMySQLSourceFactory();
    mysqlCDCFactory.startupOptions = "latest";
    final String tabName = "base";
    CUDCDCTestSuit cdcTestSuit = new CUDCDCTestSuit() {

        @Override
        protected BasicDataSourceFactory createDataSourceFactory(TargetResName dataxName) {
            return createMySqlDataSourceFactory(dataxName);
        }

        @Override
        protected String getColEscape() {
            return "`";
        }
    };
    cdcTestSuit.startTest(mysqlCDCFactory, tabName);
}
Also used : TargetResName(com.qlangtech.tis.coredefine.module.action.TargetResName) CUDCDCTestSuit(com.qlangtech.plugins.incr.flink.cdc.CUDCDCTestSuit) Test(org.junit.Test)

Example 9 with TargetResName

use of com.qlangtech.tis.coredefine.module.action.TargetResName in project plugins by qlangtech.

the class TestTISFlinkCDCOracleSourceFunction method testBinlogConsume.

@Test
public void testBinlogConsume() throws Exception {
    FlinkCDCOracleSourceFactory mysqlCDCFactory = new FlinkCDCOracleSourceFactory();
    mysqlCDCFactory.startupOptions = "latest";
    // debezium
    final String tabName = "DEBEZIUM.BASE";
    CUDCDCTestSuit cdcTestSuit = new CUDCDCTestSuit() {

        @Override
        protected BasicDataSourceFactory createDataSourceFactory(TargetResName dataxName) {
            return createMySqlDataSourceFactory(dataxName);
        }

        @Override
        protected void startProcessConn(Connection conn) throws SQLException {
            conn.setAutoCommit(false);
        }

        @Override
        protected int executePreparedStatement(Connection connection, PreparedStatement statement) throws SQLException {
            int count = super.executePreparedStatement(connection, statement);
            connection.commit();
            return count;
        }

        @Override
        protected int executeStatement(Connection connection, Statement statement, String sql) throws SQLException {
            int count = super.executeStatement(connection, statement, sql);
            connection.commit();
            return count;
        }
    };
    cdcTestSuit.startTest(mysqlCDCFactory, tabName);
}
Also used : TargetResName(com.qlangtech.tis.coredefine.module.action.TargetResName) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) CUDCDCTestSuit(com.qlangtech.plugins.incr.flink.cdc.CUDCDCTestSuit)

Example 10 with TargetResName

use of com.qlangtech.tis.coredefine.module.action.TargetResName in project plugins by qlangtech.

the class TestFlinkCDCPostgreSQLSourceFunction method testBinlogConsume.

@Test
public void testBinlogConsume() throws Exception {
    FlinkCDCPostreSQLSourceFactory pgCDCFactory = new FlinkCDCPostreSQLSourceFactory();
    final String tabName = "base";
    CUDCDCTestSuit cdcTestSuit = new CUDCDCTestSuit() {

        @Override
        protected BasicDataSourceFactory createDataSourceFactory(TargetResName dataxName) {
            return createPGDataSourceFactory(dataxName);
        }

        @Override
        protected int executePreparedStatement(Connection connection, PreparedStatement statement) throws SQLException {
            int updateCount = super.executePreparedStatement(connection, statement);
            connection.commit();
            return updateCount;
        }

        @Override
        protected String createTableName(String tabName) {
            return schemaName + "." + tabName;
        }

        @Override
        protected int executeStatement(Connection connection, java.sql.Statement statement, String sql) throws SQLException {
            int updateCount = super.executeStatement(connection, statement, sql);
            connection.commit();
            return updateCount;
        }

        @Override
        protected void startProcessConn(Connection conn) throws SQLException {
            super.startProcessConn(conn);
            conn.setAutoCommit(false);
        }
    };
    cdcTestSuit.startTest(pgCDCFactory, tabName);
}
Also used : TargetResName(com.qlangtech.tis.coredefine.module.action.TargetResName) PreparedStatement(java.sql.PreparedStatement) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) CUDCDCTestSuit(com.qlangtech.plugins.incr.flink.cdc.CUDCDCTestSuit) Test(org.junit.Test)

Aggregations

TargetResName (com.qlangtech.tis.coredefine.module.action.TargetResName)19 CUDCDCTestSuit (com.qlangtech.plugins.incr.flink.cdc.CUDCDCTestSuit)5 IRCController (com.qlangtech.tis.coredefine.module.action.IRCController)5 ISelectedTab (com.qlangtech.tis.plugin.ds.ISelectedTab)5 Collectors (java.util.stream.Collectors)5 IMQListener (com.qlangtech.tis.async.message.client.consumer.IMQListener)4 MQConsumeException (com.qlangtech.tis.async.message.client.consumer.MQConsumeException)4 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)4 BasicDataXRdbmsReader (com.qlangtech.tis.plugin.datax.common.BasicDataXRdbmsReader)4 BasicDataSourceFactory (com.qlangtech.tis.plugin.ds.BasicDataSourceFactory)4 List (java.util.List)4 JobExecutionResult (org.apache.flink.api.common.JobExecutionResult)4 SourceChannel (com.qlangtech.plugins.incr.flink.cdc.SourceChannel)3 TISDeserializationSchema (com.qlangtech.plugins.incr.flink.cdc.TISDeserializationSchema)3 IAsyncMsgDeserialize (com.qlangtech.tis.async.message.client.consumer.IAsyncMsgDeserialize)3 IConsumerHandle (com.qlangtech.tis.async.message.client.consumer.IConsumerHandle)3 IDataxReader (com.qlangtech.tis.datax.IDataxReader)3 ReaderSource (com.qlangtech.tis.realtime.ReaderSource)3 DTO (com.qlangtech.tis.realtime.transfer.DTO)3 Test (org.junit.Test)3