AE86 3 年之前
父节点
当前提交
8d462472e7

+ 4 - 31
dbsyncer-parser/src/main/java/org/dbsyncer/parser/ParserFactory.java

@@ -27,12 +27,10 @@ import org.dbsyncer.parser.util.ConvertUtil;
 import org.dbsyncer.parser.util.PickerUtil;
 import org.dbsyncer.plugin.PluginFactory;
 import org.dbsyncer.storage.enums.StorageDataStatusEnum;
-import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.ApplicationContext;
@@ -174,7 +172,6 @@ public class ParserFactory implements Parser {
         try {
             JSONObject conn = new JSONObject(json);
             JSONObject config = (JSONObject) conn.remove("config");
-            JSONArray table = (JSONArray) conn.remove("table");
             Connector connector = JsonUtil.jsonToObj(conn.toString(), Connector.class);
             Assert.notNull(connector, "Connector can not be null.");
             String connectorType = config.getString("connectorType");
@@ -182,19 +179,6 @@ public class ParserFactory implements Parser {
             ConnectorConfig obj = (ConnectorConfig) JsonUtil.jsonToObj(config.toString(), configClass);
             connector.setConfig(obj);
 
-            List<Table> tableList = new ArrayList<>();
-            boolean exist = false;
-            for (int i = 0; i < table.length(); i++) {
-                if (table.get(i) instanceof String) {
-                    tableList.add(new Table(table.getString(i)));
-                    exist = true;
-                }
-            }
-            if (!exist) {
-                tableList = JsonUtil.jsonToArray(table.toString(), Table.class);
-            }
-            connector.setTable(tableList);
-
             return connector;
         } catch (JSONException e) {
             logger.error(e.getMessage());
@@ -204,16 +188,8 @@ public class ParserFactory implements Parser {
 
     @Override
     public <T> T parseObject(String json, Class<T> clazz) {
-        try {
-            JSONObject obj = new JSONObject(json);
-            T t = JsonUtil.jsonToObj(obj.toString(), clazz);
-            String format = String.format("%s can not be null.", clazz.getSimpleName());
-            Assert.notNull(t, format);
-            return t;
-        } catch (JSONException e) {
-            logger.error(e.getMessage());
-            throw new ParserException(e.getMessage());
-        }
+        T t = JsonUtil.jsonToObj(json, clazz);
+        return t;
     }
 
     @Override
@@ -430,9 +406,7 @@ public class ParserFactory implements Parser {
         Assert.hasText(connectorId, "Connector id can not be empty.");
         Connector conn = cacheService.get(connectorId, Connector.class);
         Assert.notNull(conn, "Connector can not be null.");
-        Connector connector = new Connector();
-        BeanUtils.copyProperties(conn, connector);
-        return connector;
+        return conn;
     }
 
     /**
@@ -442,8 +416,7 @@ public class ParserFactory implements Parser {
      * @return
      */
     private ConnectorConfig getConnectorConfig(String connectorId) {
-        Connector connector = getConnector(connectorId);
-        return connector.getConfig();
+        return getConnector(connectorId).getConfig();
     }
 
 }

+ 2 - 1
dbsyncer-parser/src/main/java/org/dbsyncer/parser/flush/AbstractBufferActuator.java

@@ -98,7 +98,7 @@ public abstract class AbstractBufferActuator<Request, Response> implements Buffe
         boolean locked = false;
         try {
             locked = bufferLock.tryLock();
-            if (locked && !running) {
+            if (locked) {
                 running = true;
                 flush(buffer);
                 running = false;
@@ -108,6 +108,7 @@ public abstract class AbstractBufferActuator<Request, Response> implements Buffe
             logger.error(e.getMessage());
         } finally {
             if (locked) {
+                running = false;
                 bufferLock.unlock();
             }
         }

+ 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=20
-dbsyncer.web.thread.pool.queue.capacity=5000
+dbsyncer.web.thread.pool.core.size=10
+dbsyncer.web.thread.pool.queue.capacity=2000
 server.servlet.session.timeout=1800
 server.servlet.context-path=/