use of com.ververica.cdc.connectors.mysql.source.MySqlSource in project flink-cdc-connectors by ververica.
the class MySqlTableSource method getScanRuntimeProvider.
@Override
public ScanRuntimeProvider getScanRuntimeProvider(ScanContext scanContext) {
RowType physicalDataType = (RowType) physicalSchema.toPhysicalRowDataType().getLogicalType();
MetadataConverter[] metadataConverters = getMetadataConverters();
final TypeInformation<RowData> typeInfo = scanContext.createTypeInformation(producedDataType);
DebeziumDeserializationSchema<RowData> deserializer = RowDataDebeziumDeserializeSchema.newBuilder().setPhysicalRowType(physicalDataType).setMetadataConverters(metadataConverters).setResultTypeInfo(typeInfo).setServerTimeZone(serverTimeZone).setUserDefinedConverterFactory(MySqlDeserializationConverterFactory.instance()).build();
if (enableParallelRead) {
MySqlSource<RowData> parallelSource = MySqlSource.<RowData>builder().hostname(hostname).port(port).databaseList(database).tableList(database + "." + tableName).username(username).password(password).serverTimeZone(serverTimeZone.toString()).serverId(serverId).splitSize(splitSize).splitMetaGroupSize(splitMetaGroupSize).distributionFactorUpper(distributionFactorUpper).distributionFactorLower(distributionFactorLower).fetchSize(fetchSize).connectTimeout(connectTimeout).connectMaxRetries(connectMaxRetries).connectionPoolSize(connectionPoolSize).debeziumProperties(dbzProperties).startupOptions(startupOptions).deserializer(deserializer).scanNewlyAddedTableEnabled(scanNewlyAddedTableEnabled).jdbcProperties(jdbcProperties).heartbeatInterval(heartbeatInterval).build();
return SourceProvider.of(parallelSource);
} else {
com.ververica.cdc.connectors.mysql.MySqlSource.Builder<RowData> builder = com.ververica.cdc.connectors.mysql.MySqlSource.<RowData>builder().hostname(hostname).port(port).databaseList(database).tableList(database + "." + tableName).username(username).password(password).serverTimeZone(serverTimeZone.toString()).debeziumProperties(dbzProperties).startupOptions(startupOptions).deserializer(deserializer);
Optional.ofNullable(serverId).ifPresent(serverId -> builder.serverId(Integer.parseInt(serverId)));
DebeziumSourceFunction<RowData> sourceFunction = builder.build();
return SourceFunctionProvider.of(sourceFunction, false);
}
}
Aggregations