use of com.github.jcustenborder.kafka.connect.cdc.ChangeKey in project kafka-connect-cdc-mssql by jcustenborder.
the class QueryService method changeKey.
ChangeKey changeKey(String changeTrackingTable) {
Matcher matcher = CHANGE_TRACKING_TABLE_PATTERN.matcher(changeTrackingTable);
Preconditions.checkState(matcher.matches(), "'%s' is not formatted in properly. Use 'schemaName.databaseName.tableName'.", changeTrackingTable);
String schemaName = matcher.group(1);
String tableName = matcher.group(2);
return new ChangeKey(this.config.initialDatabase, schemaName, tableName);
}
use of com.github.jcustenborder.kafka.connect.cdc.ChangeKey in project kafka-connect-cdc-mssql by jcustenborder.
the class QueryService method processTables.
void processTables() throws SQLException {
for (String changeTrackingTable : Iterables.cycle(this.config.changeTrackingTables)) {
if (!isRunning()) {
break;
}
rateLimiter.acquire();
ChangeKey changeKey;
try {
changeKey = changeKey(changeTrackingTable);
} catch (Exception ex) {
log.error("Exception thrown while parsing table name '{}'", changeTrackingTable, ex);
continue;
}
try {
queryTable(this.changeWriter, changeKey);
} catch (Exception ex) {
log.error("Exception thrown while querying for {}", changeKey, ex);
}
}
}
use of com.github.jcustenborder.kafka.connect.cdc.ChangeKey in project kafka-connect-cdc-mssql by jcustenborder.
the class MsSqlTableMetadataProviderIT method tableMetadata.
private void tableMetadata(MsSqlTableMetadataProviderTestData data) throws SQLException {
assertNotNull(data, "data should not be null.");
TableMetadataProvider.TableMetadata actual = this.tableMetadataProvider.tableMetadata(new ChangeKey(data.databaseName(), data.schemaName(), data.tableName()));
assertTableMetadata(data.expected(), actual);
}
use of com.github.jcustenborder.kafka.connect.cdc.ChangeKey in project kafka-connect-cdc-mssql by jcustenborder.
the class QueryServiceIT method queryTable.
@TestFactory
public Stream<DynamicTest> queryTable() throws SQLException {
List<ChangeKey> changeCaptureTables = new ArrayList<>();
PooledConnection pooledConnection = null;
try {
pooledConnection = JdbcUtils.openPooledConnection(this.config, new ChangeKey(MsSqlTestConstants.DATABASE_NAME, null, null));
MsSqlQueryBuilder queryBuilder = new MsSqlQueryBuilder(pooledConnection.getConnection());
try (PreparedStatement statement = queryBuilder.listChangeTrackingTablesStatement()) {
try (ResultSet resultSet = statement.executeQuery()) {
while (resultSet.next()) {
String databaseName = resultSet.getString("databaseName");
String schemaName = resultSet.getString("schemaName");
String tableName = resultSet.getString("tableName");
ChangeKey changeKey = new ChangeKey(databaseName, schemaName, tableName);
changeCaptureTables.add(changeKey);
log.trace("Found Change Tracking Enabled Table {}", changeKey);
}
}
}
} finally {
JdbcUtils.closeConnection(pooledConnection);
}
return changeCaptureTables.stream().map(data -> dynamicTest(data.tableName, () -> queryTable(data)));
}
Aggregations