Search in sources :

Example 1 with MySqlSource

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);
    }
}
Also used : RowData(org.apache.flink.table.data.RowData) MySqlSource(com.ververica.cdc.connectors.mysql.source.MySqlSource) MetadataConverter(com.ververica.cdc.debezium.table.MetadataConverter) RowType(org.apache.flink.table.types.logical.RowType)

Aggregations

MySqlSource (com.ververica.cdc.connectors.mysql.source.MySqlSource)1 MetadataConverter (com.ververica.cdc.debezium.table.MetadataConverter)1 RowData (org.apache.flink.table.data.RowData)1 RowType (org.apache.flink.table.types.logical.RowType)1