/**
         * Load table meta data.
         *
         * @param logicTableName logic table name
         * @param databaseType database type
         * @return table meta data
         * @throws SQLException SQL exception
         */
        public TableMetaData Load(string logicTableName, IDatabaseType databaseType)
        {
            TableRule tableRule = shardingRule.GetTableRule(logicTableName);

            if (!isCheckingMetaData)
            {
                DataNode dataNode = tableRule.ActualDataNodes.First();
                var      rawMasterDataSourceName = shardingRule.ShardingDataSourceNames.GetRawMasterDataSourceName(dataNode.GetDataSourceName());
                return(TableMetaDataLoader.Load(dataSourceMap[rawMasterDataSourceName], dataNode.GetTableName(), databaseType.GetName()));
            }
            var dataNodeGroups = tableRule.GetDataNodeGroups();
            ConcurrentDictionary <string, TableMetaData> actualTableMetaDataMap = new ConcurrentDictionary <string, TableMetaData>();

            var tasks = dataNodeGroups.SelectMany(o => o.Value.Select(dataNode => Task.Run(() =>
            {
                var tableMetaData = Load(dataNode, databaseType);
                actualTableMetaDataMap.TryAdd(dataNode.GetTableName(), tableMetaData);
            }))).ToArray();

            Task.WaitAll(tasks);


            CheckUniformed(logicTableName, actualTableMetaDataMap);
            return(actualTableMetaDataMap.Select(o => o.Value).FirstOrDefault());
        }
 private TableMetaData Load(DataNode dataNode, IDatabaseType databaseType)
 {
     try
     {
         return(TableMetaDataLoader.Load(dataSourceMap[dataNode.GetDataSourceName()], dataNode.GetTableName(), databaseType.GetName()));
     }
     catch (Exception e)
     {
         throw new ShardingException($"SqlException for DataNode={dataNode} and databaseType={databaseType.GetName()}", e);
     }
 }