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);
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations