You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2023/06/25 15:05:40 UTC
[shardingsphere] branch master updated: Fix sonar issue for ConfigurationChangedSubscriber (#26554)
This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 d1983dc871f Fix sonar issue for ConfigurationChangedSubscriber (#26554)
d1983dc871f is described below
commit d1983dc871fab215ab4d04ed698aa341951c2513
Author: zhaojinchao <zh...@apache.org>
AuthorDate: Sun Jun 25 23:05:34 2023 +0800
Fix sonar issue for ConfigurationChangedSubscriber (#26554)
* Fix sonar issue for ConfigurationChangedSubscriber
* Fix checkstyle
---
.../mode/manager/cluster/ClusterContextManagerBuilder.java | 6 +++---
.../coordinator/subscriber/ConfigurationChangedSubscriber.java | 6 +-----
.../coordinator/subscriber/ContextManagerSubscriberFacade.java | 5 ++---
.../coordinator/subscriber/ConfigurationChangedSubscriberTest.java | 6 +-----
4 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index 47e02cdb2d9..c976350520a 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -56,7 +56,7 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
MetaDataContexts metaDataContexts = MetaDataContextsFactory.create(persistService, param, instanceContext, registryCenter.getStorageNodeStatusService().loadStorageNodes());
ContextManager result = new ContextManager(metaDataContexts, instanceContext);
setContextManagerAware(result);
- registerOnline(persistService, registryCenter, param, result);
+ registerOnline(registryCenter, param, result);
return result;
}
@@ -76,12 +76,12 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
((ContextManagerAware) contextManager.getInstanceContext().getModeContextManager()).setContextManagerAware(contextManager);
}
- private void registerOnline(final MetaDataPersistService persistService, final RegistryCenter registryCenter, final ContextManagerBuilderParameter param, final ContextManager contextManager) {
+ private void registerOnline(final RegistryCenter registryCenter, final ContextManagerBuilderParameter param, final ContextManager contextManager) {
registryCenter.onlineInstance(contextManager.getInstanceContext().getInstance());
loadClusterStatus(registryCenter, contextManager);
contextManager.getInstanceContext().getInstance().setLabels(param.getLabels());
contextManager.getInstanceContext().getAllClusterInstances().addAll(registryCenter.getComputeNodeStatusService().loadAllComputeNodeInstances());
- new ContextManagerSubscriberFacade(persistService, registryCenter, contextManager);
+ new ContextManagerSubscriberFacade(registryCenter, contextManager);
}
private void loadClusterStatus(final RegistryCenter registryCenter, final ContextManager contextManager) {
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriber.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriber.java
index daaa9c41033..acd50bd9f7f 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriber.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriber.java
@@ -28,7 +28,6 @@ import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.confi
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.props.PropertiesChangedEvent;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.GlobalRuleConfigurationsChangedEvent;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.RuleConfigurationsChangedEvent;
-import org.apache.shardingsphere.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.mode.event.storage.StorageNodeDataSource;
import org.apache.shardingsphere.mode.event.storage.StorageNodeDataSourceChangedEvent;
@@ -43,14 +42,11 @@ import java.util.stream.Collectors;
@SuppressWarnings("UnstableApiUsage")
public final class ConfigurationChangedSubscriber {
- private final MetaDataPersistService persistService;
-
private final RegistryCenter registryCenter;
private final ContextManager contextManager;
- public ConfigurationChangedSubscriber(final MetaDataPersistService persistService, final RegistryCenter registryCenter, final ContextManager contextManager) {
- this.persistService = persistService;
+ public ConfigurationChangedSubscriber(final RegistryCenter registryCenter, final ContextManager contextManager) {
this.registryCenter = registryCenter;
this.contextManager = contextManager;
contextManager.getInstanceContext().getEventBusContext().register(this);
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ContextManagerSubscriberFacade.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ContextManagerSubscriberFacade.java
index 6bcd6f74c0b..8b061ae691c 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ContextManagerSubscriberFacade.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ContextManagerSubscriberFacade.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.mode.manager.cluster.coordinator.subscriber;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.RegistryCenter;
-import org.apache.shardingsphere.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.subscriber.ProcessListChangedSubscriber;
/**
@@ -27,8 +26,8 @@ import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.proce
*/
public final class ContextManagerSubscriberFacade {
- public ContextManagerSubscriberFacade(final MetaDataPersistService persistService, final RegistryCenter registryCenter, final ContextManager contextManager) {
- new ConfigurationChangedSubscriber(persistService, registryCenter, contextManager);
+ public ContextManagerSubscriberFacade(final RegistryCenter registryCenter, final ContextManager contextManager) {
+ new ConfigurationChangedSubscriber(registryCenter, contextManager);
new ResourceMetaDataChangedSubscriber(contextManager);
new DatabaseChangedSubscriber(contextManager);
new StateChangedSubscriber(registryCenter, contextManager);
diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriberTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriberTest.java
index 28c5b9b85e9..f1eed424c1b 100644
--- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriberTest.java
+++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ConfigurationChangedSubscriberTest.java
@@ -46,7 +46,6 @@ import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.confi
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.GlobalRuleConfigurationsChangedEvent;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.RuleConfigurationsChangedEvent;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
import org.apache.shardingsphere.sqltranslator.rule.SQLTranslatorRule;
@@ -87,9 +86,6 @@ class ConfigurationChangedSubscriberTest {
private ContextManager contextManager;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private MetaDataPersistService persistService;
-
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ShardingSphereDatabase database;
@@ -101,7 +97,7 @@ class ConfigurationChangedSubscriberTest {
contextManager = new ClusterContextManagerBuilder().build(createContextManagerBuilderParameter());
contextManager.renewMetaDataContexts(new MetaDataContexts(contextManager.getMetaDataContexts().getPersistService(), new ShardingSphereMetaData(createDatabases(),
contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData(), new ConfigurationProperties(new Properties()))));
- subscriber = new ConfigurationChangedSubscriber(persistService, new RegistryCenter(mock(ClusterPersistRepository.class),
+ subscriber = new ConfigurationChangedSubscriber(new RegistryCenter(mock(ClusterPersistRepository.class),
new EventBusContext(), mock(ProxyInstanceMetaData.class), null), contextManager);
}