This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 f215142 Fixed Discovery heartbeat job not work. (#14339)
f215142 is described below
commit f2151421374e3e5a856f82a7283de4d3bb0ad154
Author: zhaojinchao <[email protected]>
AuthorDate: Mon Dec 27 14:09:45 2021 +0800
Fixed Discovery heartbeat job not work. (#14339)
---
.../apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java | 2 +-
.../mode/manager/cluster/ClusterContextManagerBuilder.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
index 203ea2e..2dd3736 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
@@ -190,7 +190,7 @@ public final class DatabaseDiscoveryRule implements
SchemaRule, DataSourceContai
Optional<ModeScheduleContext> modeScheduleContext =
ModeScheduleContextFactory.getInstance().get();
if (modeScheduleContext.isPresent()) {
for (Entry<String, DatabaseDiscoveryDataSourceRule> entry :
dataSourceRules.entrySet()) {
- Map<String, DataSource> dataSources =
dataSourceMap.entrySet().stream().filter(dataSource ->
entry.getValue().getDisabledDataSourceNames().contains(dataSource.getKey()))
+ Map<String, DataSource> dataSources =
dataSourceMap.entrySet().stream().filter(dataSource ->
!entry.getValue().getDisabledDataSourceNames().contains(dataSource.getKey()))
.collect(Collectors.toMap(Entry::getKey,
Entry::getValue));
CronJob job = new
CronJob(entry.getValue().getDatabaseDiscoveryType().getType() + "-" +
entry.getValue().getName(),
each -> new HeartbeatJob(schemaName, dataSources,
entry.getValue().getName(), entry.getValue().getDatabaseDiscoveryType(),
entry.getValue().getDisabledDataSourceNames())
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index 01e42939..34fbb5e 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -83,7 +83,6 @@ public final class ClusterContextManagerBuilder implements
ContextManagerBuilder
beforeBuildContextManager(modeConfig, dataSourcesMap,
schemaRuleConfigs, globalRuleConfigs, props, isOverwrite, port, schemaName);
contextManager = new ContextManager();
contextManager.init(metaDataContexts, transactionContexts, null);
- ModeScheduleContextFactory.getInstance().init(modeConfig);
afterBuildContextManager();
return contextManager;
}
@@ -93,6 +92,7 @@ public final class ClusterContextManagerBuilder implements
ContextManagerBuilder
final Properties props, final
boolean isOverwrite, final Integer port, final String schemaName) throws
SQLException {
ClusterPersistRepository repository =
createClusterPersistRepository((ClusterPersistRepositoryConfiguration)
modeConfig.getRepository());
registryCenter = new RegistryCenter(repository, port);
+ ModeScheduleContextFactory.getInstance().init(modeConfig);
metaDataPersistService = new MetaDataPersistService(repository);
persistConfigurations(metaDataPersistService, dataSourcesMap,
schemaRuleConfigs, globalRuleConfigs, props, isOverwrite);
Collection<String> schemaNames = Strings.isNullOrEmpty(schemaName) ?
metaDataPersistService.getSchemaMetaDataService().loadAllNames() :
Arrays.asList(schemaName);