-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'apache:dev' into connector-teradata
- Loading branch information
Showing
16 changed files
with
854 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
...tor-cdc-base/src/main/java/org/seatunnel/connectors/cdc/base/config/JdbcSourceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.seatunnel.connectors.cdc.base.config; | ||
|
||
import io.debezium.relational.RelationalDatabaseConnectorConfig; | ||
import org.seatunnel.connectors.cdc.base.source.IncrementalSource; | ||
|
||
import java.time.Duration; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
/** | ||
* A Source configuration which is used by {@link IncrementalSource} which used JDBC data source. | ||
*/ | ||
public abstract class JdbcSourceConfig extends BaseSourceConfig { | ||
|
||
protected final String driverClassName; | ||
protected final String hostname; | ||
protected final int port; | ||
protected final String username; | ||
protected final String password; | ||
protected final List<String> databaseList; | ||
protected final List<String> tableList; | ||
protected final int fetchSize; | ||
protected final String serverTimeZone; | ||
protected final Duration connectTimeout; | ||
protected final int connectMaxRetries; | ||
protected final int connectionPoolSize; | ||
|
||
public JdbcSourceConfig( | ||
StartupConfig startupConfig, | ||
StopConfig stopConfig, | ||
List<String> databaseList, | ||
List<String> tableList, | ||
int splitSize, | ||
double distributionFactorUpper, | ||
double distributionFactorLower, | ||
Properties dbzProperties, | ||
String driverClassName, | ||
String hostname, | ||
int port, | ||
String username, | ||
String password, | ||
int fetchSize, | ||
String serverTimeZone, | ||
Duration connectTimeout, | ||
int connectMaxRetries, | ||
int connectionPoolSize) { | ||
super( | ||
startupConfig, | ||
stopConfig, | ||
splitSize, | ||
distributionFactorUpper, | ||
distributionFactorLower, | ||
dbzProperties); | ||
this.driverClassName = driverClassName; | ||
this.hostname = hostname; | ||
this.port = port; | ||
this.username = username; | ||
this.password = password; | ||
this.databaseList = databaseList; | ||
this.tableList = tableList; | ||
this.fetchSize = fetchSize; | ||
this.serverTimeZone = serverTimeZone; | ||
this.connectTimeout = connectTimeout; | ||
this.connectMaxRetries = connectMaxRetries; | ||
this.connectionPoolSize = connectionPoolSize; | ||
} | ||
|
||
public abstract RelationalDatabaseConnectorConfig getDbzConnectorConfig(); | ||
|
||
public String getDriverClassName() { | ||
return driverClassName; | ||
} | ||
|
||
public String getHostname() { | ||
return hostname; | ||
} | ||
|
||
public int getPort() { | ||
return port; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public List<String> getDatabaseList() { | ||
return databaseList; | ||
} | ||
|
||
public List<String> getTableList() { | ||
return tableList; | ||
} | ||
|
||
public int getFetchSize() { | ||
return fetchSize; | ||
} | ||
|
||
public String getServerTimeZone() { | ||
return serverTimeZone; | ||
} | ||
|
||
public Duration getConnectTimeout() { | ||
return connectTimeout; | ||
} | ||
|
||
public int getConnectMaxRetries() { | ||
return connectMaxRetries; | ||
} | ||
|
||
public int getConnectionPoolSize() { | ||
return connectionPoolSize; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...c-base/src/main/java/org/seatunnel/connectors/cdc/base/dialect/JdbcDataSourceDialect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.seatunnel.connectors.cdc.base.dialect; | ||
|
||
import org.apache.seatunnel.common.utils.SeaTunnelException; | ||
|
||
import io.debezium.jdbc.JdbcConnection; | ||
import io.debezium.relational.TableId; | ||
import org.seatunnel.connectors.cdc.base.config.JdbcSourceConfig; | ||
import org.seatunnel.connectors.cdc.base.relational.connection.JdbcConnectionFactory; | ||
import org.seatunnel.connectors.cdc.base.relational.connection.JdbcConnectionPoolFactory; | ||
import org.seatunnel.connectors.cdc.base.source.reader.external.FetchTask; | ||
import org.seatunnel.connectors.cdc.base.source.reader.external.JdbcSourceFetchTaskContext; | ||
import org.seatunnel.connectors.cdc.base.source.split.SourceSplitBase; | ||
|
||
import java.util.List; | ||
|
||
public interface JdbcDataSourceDialect extends DataSourceDialect<JdbcSourceConfig> { | ||
|
||
/** Discovers the list of table to capture. */ | ||
@Override | ||
List<TableId> discoverDataCollections(JdbcSourceConfig sourceConfig); | ||
|
||
/** | ||
* Creates and opens a new {@link JdbcConnection} backing connection pool. | ||
* | ||
* @param sourceConfig a basic source configuration. | ||
* @return a utility that simplifies using a JDBC connection. | ||
*/ | ||
default JdbcConnection openJdbcConnection(JdbcSourceConfig sourceConfig) { | ||
JdbcConnection jdbc = | ||
new JdbcConnection( | ||
sourceConfig.getDbzConfiguration(), | ||
new JdbcConnectionFactory(sourceConfig, getPooledDataSourceFactory())); | ||
try { | ||
jdbc.connect(); | ||
} catch (Exception e) { | ||
throw new SeaTunnelException(e); | ||
} | ||
return jdbc; | ||
} | ||
|
||
/** Get a connection pool factory to create connection pool. */ | ||
JdbcConnectionPoolFactory getPooledDataSourceFactory(); | ||
|
||
@Override | ||
FetchTask<SourceSplitBase> createFetchTask(SourceSplitBase sourceSplitBase); | ||
|
||
@Override | ||
JdbcSourceFetchTaskContext createFetchTaskContext( | ||
SourceSplitBase sourceSplitBase, JdbcSourceConfig taskSourceConfig); | ||
} |
Oops, something went wrong.