This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 3ceb617 Persist decorated meta data instead of actual (#14012)
3ceb617 is described below
commit 3ceb61743be7f17026c16689993a69158f512a17
Author: Haoran Meng <[email protected]>
AuthorDate: Thu Dec 9 16:05:44 2021 +0800
Persist decorated meta data instead of actual (#14012)
Co-authored-by: shardingsphere <[email protected]>
---
.../infra/context/refresher/MetaDataRefreshEngine.java | 18 +-----------------
1 file changed, 1 insertion(+), 17 deletions(-)
diff --git
a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefreshEngine.java
b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefreshEngine.java
index 74c7123..dbe852d 100644
---
a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefreshEngine.java
+++
b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefreshEngine.java
@@ -17,27 +17,19 @@
package org.apache.shardingsphere.infra.context.refresher;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
import
org.apache.shardingsphere.infra.federation.optimizer.metadata.FederationSchemaMetaData;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.mapper.SQLStatementEventMapper;
import
org.apache.shardingsphere.infra.metadata.mapper.SQLStatementEventMapperFactory;
-import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
-import org.apache.shardingsphere.infra.metadata.schema.loader.SchemaLoader;
import
org.apache.shardingsphere.infra.metadata.schema.event.SchemaAlteredEvent;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.infra.rule.builder.schema.SchemaRulesBuilder;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
import java.util.Optional;
/**
@@ -72,7 +64,7 @@ public final class MetaDataRefreshEngine {
Optional<MetaDataRefresher> schemaRefresher =
TypedSPIRegistry.findRegisteredService(MetaDataRefresher.class,
sqlStatement.getClass().getSuperclass().getCanonicalName(), null);
if (schemaRefresher.isPresent()) {
schemaRefresher.get().refresh(schemaMetaData, federationMetaData,
logicDataSourceNames, sqlStatement, props);
- ShardingSphereEventBus.getInstance().post(new
SchemaAlteredEvent(schemaMetaData.getName(), loadActualSchema(schemaMetaData)));
+ ShardingSphereEventBus.getInstance().post(new
SchemaAlteredEvent(schemaMetaData.getName(), schemaMetaData.getSchema()));
}
Optional<SQLStatementEventMapper> sqlStatementEventMapper =
SQLStatementEventMapperFactory.newInstance(sqlStatement);
if (sqlStatementEventMapper.isPresent()) {
@@ -80,12 +72,4 @@ public final class MetaDataRefreshEngine {
// TODO Subscribe and handle DCLStatementEvent
}
}
-
- private ShardingSphereSchema loadActualSchema(final ShardingSphereMetaData
schemaMetaData) throws SQLException {
- Map<String, Map<String, DataSource>> dataSourcesMap =
Collections.singletonMap(schemaMetaData.getName(),
schemaMetaData.getResource().getDataSources());
- Map<String, Collection<RuleConfiguration>> schemaRuleConfigs =
Collections.singletonMap(schemaMetaData.getName(),
schemaMetaData.getRuleMetaData().getConfigurations());
- Map<String, Collection<ShardingSphereRule>> rules =
SchemaRulesBuilder.buildRules(dataSourcesMap, schemaRuleConfigs,
props.getProps());
- Map<String, ShardingSphereSchema> schemas = new
SchemaLoader(dataSourcesMap, schemaRuleConfigs, rules, props.getProps()).load();
- return schemas.get(schemaMetaData.getName());
- }
}