forked from apache/eventmesh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
138 additions
and
6 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
...src/main/java/org/apache/eventmesh/common/config/connector/rdb/canal/CanalSinkConfig.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
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
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
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
68 changes: 68 additions & 0 deletions
68
...onnector-canal/src/main/java/org/apache/eventmesh/connector/canal/DatabaseConnection.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,68 @@ | ||
package org.apache.eventmesh.connector.canal; | ||
|
||
|
||
import org.apache.eventmesh.common.config.connector.rdb.canal.CanalSinkConfig; | ||
import org.apache.eventmesh.common.config.connector.rdb.canal.CanalSourceConfig; | ||
|
||
import com.alibaba.druid.pool.DruidDataSource; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
|
||
public class DatabaseConnection { | ||
|
||
private static DruidDataSource sourceDataSource; | ||
|
||
private static DruidDataSource sinkDataSource; | ||
|
||
public static CanalSourceConfig sourceConfig; | ||
|
||
public static CanalSinkConfig sinkConfig; | ||
|
||
public static void initSourceConnection() { | ||
sourceDataSource = new DruidDataSource(); | ||
sourceDataSource.setUrl(sourceConfig.getSourceConnectorConfig().getUrl()); | ||
sourceDataSource.setUsername(sourceConfig.getSourceConnectorConfig().getUserName()); | ||
sourceDataSource.setPassword(sourceConfig.getSourceConnectorConfig().getPassWord()); | ||
sourceDataSource.setInitialSize(5); | ||
sourceDataSource.setMinIdle(5); | ||
sourceDataSource.setMaxActive(20); | ||
sourceDataSource.setMaxWait(60000); | ||
sourceDataSource.setTimeBetweenEvictionRunsMillis(60000); | ||
sourceDataSource.setMinEvictableIdleTimeMillis(300000); | ||
sourceDataSource.setValidationQuery("SELECT 1"); | ||
sourceDataSource.setTestWhileIdle(true); | ||
sourceDataSource.setTestOnBorrow(false); | ||
sourceDataSource.setTestOnReturn(false); | ||
sourceDataSource.setPoolPreparedStatements(true); | ||
sourceDataSource.setMaxPoolPreparedStatementPerConnectionSize(20); | ||
} | ||
|
||
public static void initSinkConnection() { | ||
sinkDataSource = new DruidDataSource(); | ||
sinkDataSource.setUrl(sinkConfig.getSinkConnectorConfig().getUrl()); | ||
sinkDataSource.setUsername(sinkConfig.getSinkConnectorConfig().getUserName()); | ||
sinkDataSource.setPassword(sinkConfig.getSinkConnectorConfig().getPassWord()); | ||
sinkDataSource.setInitialSize(5); | ||
sinkDataSource.setMinIdle(5); | ||
sinkDataSource.setMaxActive(20); | ||
sinkDataSource.setMaxWait(60000); | ||
sinkDataSource.setTimeBetweenEvictionRunsMillis(60000); | ||
sinkDataSource.setMinEvictableIdleTimeMillis(300000); | ||
sinkDataSource.setValidationQuery("SELECT 1"); | ||
sinkDataSource.setTestWhileIdle(true); | ||
sinkDataSource.setTestOnBorrow(false); | ||
sinkDataSource.setTestOnReturn(false); | ||
sinkDataSource.setPoolPreparedStatements(true); | ||
sinkDataSource.setMaxPoolPreparedStatementPerConnectionSize(20); | ||
} | ||
|
||
|
||
public static Connection getSourceConnection() throws SQLException { | ||
return sourceDataSource.getConnection(); | ||
} | ||
|
||
public static Connection getSinkConnection() throws SQLException { | ||
return sinkDataSource.getConnection(); | ||
} | ||
} |
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