You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/08/24 07:54:20 UTC

[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #11976: refactor parallel check meta data, refactor TableMetaDataLoaderEngine.

strongduanmu commented on a change in pull request #11976:
URL: https://github.com/apache/shardingsphere/pull/11976#discussion_r694590326



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/TableMetaDataLoaderEngine.java
##########
@@ -46,6 +47,21 @@
     private static final ExecutorService EXECUTOR_SERVICE = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors() * 2, Runtime.getRuntime().availableProcessors() * 2,
             0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setDaemon(true).setNameFormat("ShardingSphere-TableMetaDataLoaderEngine-%d").build());
     
+    /**
+     * Load table meta data.
+     *
+     * @param dataSource data source
+     * @param tableName table name
+     * @param databaseType database type
+     * @return table meta data
+     * @throws SQLException SQL exception
+     */
+    public static Optional<TableMetaData> load(final DataSource dataSource, final String tableName, final DatabaseType databaseType) throws SQLException {
+        Map<String, Collection<String>> dataSourceTable = Collections.singletonMap("ds", Collections.singleton(tableName));

Review comment:
       @tuichenchuxin Please don't hard code here.

##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/util/TableMetaDataUtil.java
##########
@@ -55,4 +58,24 @@
         }
         return result;
     }
+    
+    /**
+     * Get data source all actual table groups.
+     *
+     * @param tableNames table name collection
+     * @param materials materials
+     * @return datasource and table collection map
+     */
+    public static Map<String, Collection<String>> getDataSourceAllActualTableGroups(final Collection<String> tableNames, final SchemaBuilderMaterials materials) {

Review comment:
       @tuichenchuxin You may consider publishing a community task to add test cases for TableMetaDataUtil.

##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/TableMetaDataLoaderEngine.java
##########
@@ -58,8 +74,14 @@
     public static Collection<TableMetaData> load(final Map<String, Collection<String>> dataSourceTable, final DatabaseType databaseType,
                                                  final Map<String, DataSource> dataSourceMap) throws SQLException {
         Optional<DialectTableMetaDataLoader> dialectTableMetaDataLoader = findDialectTableMetaDataLoader(databaseType);
-        return dialectTableMetaDataLoader.isPresent() ? loadByDialect(dialectTableMetaDataLoader.get(), dataSourceTable, dataSourceMap)
-                : loadByDefault(dataSourceTable, databaseType, dataSourceMap);
+        if (dialectTableMetaDataLoader.isPresent()) {
+            try {
+                return loadByDialect(dialectTableMetaDataLoader.get(), dataSourceTable, dataSourceMap);
+            } catch (SQLException e) {
+                return loadByDefault(dataSourceTable, databaseType, dataSourceMap);

Review comment:
       @tuichenchuxin Please print out the exception information and modify the exception variables.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org