This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new bf60a90  Optimize Dumper (#8371)
bf60a90 is described below

commit bf60a906234208bc3675da16076fea6af82dd192
Author: 邱鹿 Lucas <[email protected]>
AuthorDate: Fri Nov 27 17:37:19 2020 +0800

    Optimize Dumper (#8371)
    
    Co-authored-by: qiulu3 <Lucas209910>
---
 .../core/execute/executor/dumper/DumperFactory.java      | 16 ++--------------
 .../scaling/mysql/component/MySQLBinlogDumper.java       |  5 ++---
 2 files changed, 4 insertions(+), 17 deletions(-)

diff --git 
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/dumper/DumperFactory.java
 
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/dumper/DumperFactory.java
index eae09af..3e59be4 100644
--- 
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/dumper/DumperFactory.java
+++ 
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/dumper/DumperFactory.java
@@ -40,21 +40,9 @@ public final class DumperFactory {
      * @param dataSourceManager data source factory
      * @return JDBC dumper
      */
-    public static JDBCDumper newInstanceJdbcDumper(final 
InventoryDumperConfiguration inventoryDumperConfig, final DataSourceManager 
dataSourceManager) {
-        return 
newInstanceJdbcDumper(inventoryDumperConfig.getDataSourceConfig().getDatabaseType().getName(),
 inventoryDumperConfig, dataSourceManager);
-    }
-    
-    /**
-     * New instance of JDBC dumper.
-     *
-     * @param databaseType database type
-     * @param inventoryDumperConfig inventory dumper configuration
-     * @param dataSourceManager data source factory
-     * @return JDBC dumper
-     */
     @SneakyThrows(ReflectiveOperationException.class)
-    public static JDBCDumper newInstanceJdbcDumper(final String databaseType, 
final InventoryDumperConfiguration inventoryDumperConfig, final 
DataSourceManager dataSourceManager) {
-        ScalingEntry scalingEntry = 
ScalingEntryLoader.getScalingEntryByDatabaseType(databaseType);
+    public static JDBCDumper newInstanceJdbcDumper(final 
InventoryDumperConfiguration inventoryDumperConfig, final DataSourceManager 
dataSourceManager) {
+        ScalingEntry scalingEntry = 
ScalingEntryLoader.getScalingEntryByDatabaseType(inventoryDumperConfig.getDataSourceConfig().getDatabaseType().getName());
         return 
scalingEntry.getJdbcDumperClass().getConstructor(InventoryDumperConfiguration.class,
 DataSourceManager.class).newInstance(inventoryDumperConfig, dataSourceManager);
     }
     
diff --git 
a/shardingsphere-scaling/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/component/MySQLBinlogDumper.java
 
b/shardingsphere-scaling/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/component/MySQLBinlogDumper.java
index 1e9f400..97e2fac 100644
--- 
a/shardingsphere-scaling/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/component/MySQLBinlogDumper.java
+++ 
b/shardingsphere-scaling/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/component/MySQLBinlogDumper.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.scaling.mysql.component;
 
+import com.google.common.base.Preconditions;
 import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.metadata.schema.model.TableMetaData;
@@ -70,10 +71,8 @@ public final class MySQLBinlogDumper extends 
AbstractShardingScalingExecutor imp
     
     public MySQLBinlogDumper(final DumperConfiguration dumperConfig, final 
Position<BinlogPosition> binlogPosition) {
         this.binlogPosition = (BinlogPosition) binlogPosition;
-        if 
(!StandardJDBCDataSourceConfiguration.class.equals(dumperConfig.getDataSourceConfig().getClass()))
 {
-            throw new UnsupportedOperationException("MySQLBinlogDumper only 
support JDBCDataSourceConfiguration");
-        }
         this.dumperConfig = dumperConfig;
+        Preconditions.checkArgument(dumperConfig.getDataSourceConfig() 
instanceof StandardJDBCDataSourceConfiguration, "MySQLBinlogDumper only support 
StandardJDBCDataSourceConfiguration");
         metaDataManager = new MetaDataManager(new 
DataSourceFactory().newInstance(dumperConfig.getDataSourceConfig()));
     }
     

Reply via email to