Răsfoiți Sursa

优化入库性能

AE86 3 ani în urmă
părinte
comite
7e3f49defb

+ 4 - 0
dbsyncer-connector/src/main/java/org/dbsyncer/connector/database/ds/SimpleConnection.java

@@ -308,4 +308,8 @@ public class SimpleConnection implements Connection {
     public boolean isWrapperFor(Class<?> iface) throws SQLException {
         return false;
     }
+
+    public Connection getConnection() {
+        return connection;
+    }
 }

+ 4 - 2
dbsyncer-connector/src/main/java/org/dbsyncer/connector/database/ds/SimpleDataSource.java

@@ -2,7 +2,6 @@ package org.dbsyncer.connector.database.ds;
 
 import org.dbsyncer.connector.ConnectorException;
 import org.dbsyncer.connector.util.DatabaseUtil;
-import org.slf4j.LoggerFactory;
 
 import javax.sql.DataSource;
 import java.io.PrintWriter;
@@ -15,7 +14,6 @@ import java.util.logging.Logger;
 
 public class SimpleDataSource implements DataSource, AutoCloseable {
 
-    private final org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
     private final BlockingQueue<SimpleConnection> pool = new LinkedBlockingQueue<>(2000);
     private long lifeTime = 60 * 1000;
     private String url;
@@ -90,4 +88,8 @@ public class SimpleDataSource implements DataSource, AutoCloseable {
     public long getLifeTime() {
         return lifeTime;
     }
+
+    public void setLifeTime(long lifeTime) {
+        this.lifeTime = lifeTime;
+    }
 }

+ 5 - 0
dbsyncer-storage/src/main/java/org/dbsyncer/storage/support/MysqlStorageServiceImpl.java

@@ -9,6 +9,7 @@ import org.dbsyncer.connector.config.*;
 import org.dbsyncer.connector.constant.DatabaseConstant;
 import org.dbsyncer.connector.database.Database;
 import org.dbsyncer.connector.database.DatabaseConnectorMapper;
+import org.dbsyncer.connector.database.ds.SimpleConnection;
 import org.dbsyncer.connector.enums.ConnectorEnum;
 import org.dbsyncer.connector.enums.SetterEnum;
 import org.dbsyncer.connector.enums.SqlBuilderEnum;
@@ -91,6 +92,10 @@ public class MysqlStorageServiceImpl extends AbstractStorageService {
             boolean dbThanMysql8 = StringUtil.startsWith(databaseProductVersion, "8");
             Assert.isTrue(driverThanMysql8 == dbThanMysql8, String.format("当前驱动%s和数据库%s版本不一致.", driverVersion, databaseProductVersion));
 
+            if(conn instanceof SimpleConnection){
+                SimpleConnection simpleConnection = (SimpleConnection) conn;
+                conn = simpleConnection.getConnection();
+            }
             Class clazz = dbThanMysql8 ? conn.getClass() : conn.getClass().getSuperclass();
             java.lang.reflect.Field field = clazz.getDeclaredField("database");
             field.setAccessible(true);

+ 2 - 2
dbsyncer-web/src/main/resources/application.properties

@@ -4,8 +4,8 @@ server.port=18686
 #web
 dbsyncer.web.login.username=admin
 dbsyncer.web.login.password=0DPiKuNIrrVmD8IUCuw1hQxNqZc=
-dbsyncer.web.thread.pool.core.size=10
-dbsyncer.web.thread.pool.queue.capacity=1000
+dbsyncer.web.thread.pool.core.size=32
+dbsyncer.web.thread.pool.queue.capacity=2000
 server.servlet.session.timeout=1800
 server.servlet.context-path=/