This is an automated email from the ASF dual-hosted git repository.
panjuan 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 88e11d3 Persist schema after rule or data source changed in
ContextManager (#13699)
88e11d3 is described below
commit 88e11d3d2d5d3ee645340e41046be97555f09e03
Author: Haoran Meng <[email protected]>
AuthorDate: Fri Nov 19 15:15:29 2021 +0800
Persist schema after rule or data source changed in ContextManager (#13699)
Co-authored-by: shardingsphere <[email protected]>
---
.../java/org/apache/shardingsphere/mode/manager/ContextManager.java | 3 +++
.../cluster/coordinator/ClusterContextManagerCoordinatorTest.java | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
index 182769d..d936a01 100644
---
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
@@ -318,6 +318,7 @@ public final class ContextManager implements AutoCloseable {
Properties props = metaDataContexts.getProps().getProps();
Map<String, Collection<ShardingSphereRule>> rules =
SchemaRulesBuilder.buildRules(dataSourcesMap, schemaRuleConfigs, props);
Map<String, ShardingSphereSchema> schemas = new
SchemaLoader(dataSourcesMap, schemaRuleConfigs, rules, props).load();
+ metaDataContexts.getMetaDataPersistService().ifPresent(optional ->
optional.getSchemaMetaDataService().persist(originalMetaData.getName(),
schemas.get(originalMetaData.getName())));
return new MetaDataContextsBuilder(dataSourcesMap, schemaRuleConfigs,
metaDataContexts.getGlobalRuleMetaData().getConfigurations(), schemas, rules,
props)
.build(metaDataContexts.getMetaDataPersistService().orElse(null));
}
@@ -328,6 +329,7 @@ public final class ContextManager implements AutoCloseable {
Properties props = metaDataContexts.getProps().getProps();
Map<String, Collection<ShardingSphereRule>> rules =
SchemaRulesBuilder.buildRules(dataSourcesMap, schemaRuleConfigs, props);
Map<String, ShardingSphereSchema> schemas = new
SchemaLoader(dataSourcesMap, schemaRuleConfigs, rules, props).load();
+ metaDataContexts.getMetaDataPersistService().ifPresent(optional ->
optional.getSchemaMetaDataService().persist(originalMetaData.getName(),
schemas.get(originalMetaData.getName())));
return new MetaDataContextsBuilder(dataSourcesMap, schemaRuleConfigs,
metaDataContexts.getGlobalRuleMetaData().getConfigurations(), schemas, rules,
props)
.build(metaDataContexts.getMetaDataPersistService().orElse(null));
}
@@ -342,6 +344,7 @@ public final class ContextManager implements AutoCloseable {
Properties props = metaDataContexts.getProps().getProps();
Map<String, Collection<ShardingSphereRule>> rules =
SchemaRulesBuilder.buildRules(dataSourcesMap, schemaRuleConfigs, props);
Map<String, ShardingSphereSchema> schemas = new
SchemaLoader(dataSourcesMap, schemaRuleConfigs, rules, props).load();
+ metaDataContexts.getMetaDataPersistService().ifPresent(optional ->
optional.getSchemaMetaDataService().persist(originalMetaData.getName(),
schemas.get(originalMetaData.getName())));
return new MetaDataContextsBuilder(dataSourcesMap, schemaRuleConfigs,
metaDataContexts.getGlobalRuleMetaData().getConfigurations(), schemas, rules,
props)
.build(metaDataContexts.getMetaDataPersistService().orElse(null));
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
index f331613..8385cc4 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
@@ -104,7 +104,8 @@ public final class ClusterContextManagerCoordinatorTest {
ModeConfiguration configuration = new ModeConfiguration("Cluster",
persistRepositoryConfiguration, false);
ClusterContextManagerBuilder builder = new
ClusterContextManagerBuilder();
contextManager = builder.build(configuration, new HashMap<>(), new
HashMap<>(), new LinkedList<>(), new Properties(), false, null);
- contextManager.renewMetaDataContexts(new
MetaDataContexts(mock(MetaDataPersistService.class), createMetaDataMap(),
globalRuleMetaData, mock(ExecutorEngine.class),
+ contextManager.renewMetaDataContexts(new
MetaDataContexts(contextManager.getMetaDataContexts().getMetaDataPersistService().get(),
createMetaDataMap(), globalRuleMetaData,
+ mock(ExecutorEngine.class),
new ConfigurationProperties(new Properties()),
mock(OptimizerContext.class, RETURNS_DEEP_STUBS)));
contextManager.renewTransactionContexts(mock(TransactionContexts.class,
RETURNS_DEEP_STUBS));
coordinator = new
ClusterContextManagerCoordinator(metaDataPersistService, contextManager);