strongduanmu edited a comment on issue #10108:
URL: 
https://github.com/apache/shardingsphere/issues/10108#issuecomment-823001092


   > Hi @strongduanmu could you look at this one? My impression that `INDEX` 
metadata loading was in your charge?
   
   Hi @ljwps, thank you very much for your feedback.
   
   The physical table `FAQ_LOG_20210416` corresponding to the logical table 
`FAQ_LOG` needs to be created in advance, because some metadata of the sharding 
table needs to be loaded when starting.
   
   For details, please refer to the ShardingMetaDataLoader class.
   
   ```java
   public TableMetaData load(final String logicTableName, final DatabaseType 
databaseType) throws SQLException {
       TableRule tableRule = shardingRule.getTableRule(logicTableName);
       if (!isCheckingMetaData) {
           DataNode dataNode = tableRule.getActualDataNodes().iterator().next();
           return 
TableMetaDataLoader.load(dataSourceMap.get(shardingRule.getShardingDataSourceNames().getRawMasterDataSourceName(
               dataNode.getDataSourceName())), dataNode.getTableName(), 
databaseType.getName());
       }
       Map<String, List<DataNode>> dataNodeGroups = 
tableRule.getDataNodeGroups();
       Map<String, TableMetaData> actualTableMetaDataMap = new 
HashMap<>(dataNodeGroups.size(), 1);
       Map<String, Future<TableMetaData>> tableFutureMap = new 
HashMap<>(dataNodeGroups.size(), 1);
       ExecutorService executorService = 
Executors.newFixedThreadPool(Math.min(CORES * 2, dataNodeGroups.size()));
       for (Entry<String, List<DataNode>> entry : dataNodeGroups.entrySet()) {
           for (DataNode each : entry.getValue()) {
               Future<TableMetaData> futures = executorService.submit(() -> 
load(each, databaseType));
               tableFutureMap.put(each.getTableName(), futures);
           }
       }
       ...
   }
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to