diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerAware.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerAware.java index e8845bd2f0d9d..853e5651ec20c 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerAware.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerAware.java @@ -23,9 +23,9 @@ public interface ContextManagerAware { /** - * Set context manager aware. + * Set context manager. * * @param contextManager context manager */ - void setContextManagerAware(ContextManager contextManager); + void setContextManager(ContextManager contextManager); } 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 9fd2ab75d5884..1574dc48abdae 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 @@ -75,7 +75,7 @@ private InstanceContext buildInstanceContext(final RegistryCenter registryCenter } private void setContextManagerAware(final ContextManager contextManager) { - ((ContextManagerAware) contextManager.getInstanceContext().getModeContextManager()).setContextManagerAware(contextManager); + ((ContextManagerAware) contextManager.getInstanceContext().getModeContextManager()).setContextManager(contextManager); } private void registerOnline(final RegistryCenter registryCenter, final ContextManagerBuilderParameter param, final ContextManager contextManager) { diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterModeContextManager.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterModeContextManager.java index 2efacde544d0b..cde60db7dbf2e 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterModeContextManager.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterModeContextManager.java @@ -17,6 +17,7 @@ package org.apache.shardingsphere.mode.manager.cluster; +import lombok.Setter; import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; import org.apache.shardingsphere.infra.instance.mode.ModeContextManager; @@ -42,6 +43,7 @@ /** * Cluster mode context manager. */ +@Setter public final class ClusterModeContextManager implements ModeContextManager, ContextManagerAware { private ContextManager contextManager; @@ -154,9 +156,4 @@ public void alterGlobalRuleConfiguration(final RuleConfiguration toBeAlteredRule public void alterProperties(final Properties props) { contextManager.getMetaDataContexts().getPersistService().getPropsService().persist(props); } - - @Override - public void setContextManagerAware(final ContextManager contextManager) { - this.contextManager = contextManager; - } } diff --git a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java index a47e92bc809ef..8349ac4b73c77 100644 --- a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java +++ b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java @@ -67,7 +67,7 @@ private void registerSubscriber(final ContextManager contextManager) { } private void setContextManagerAware(final ContextManager contextManager) { - ((StandaloneModeContextManager) contextManager.getInstanceContext().getModeContextManager()).setContextManagerAware(contextManager); + ((StandaloneModeContextManager) contextManager.getInstanceContext().getModeContextManager()).setContextManager(contextManager); } @Override diff --git a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java index 4e9d42fc67343..93afad14b7997 100644 --- a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java +++ b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java @@ -18,6 +18,7 @@ package org.apache.shardingsphere.mode.manager.standalone; import com.google.common.base.Strings; +import lombok.Setter; import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; import org.apache.shardingsphere.infra.connection.refresher.util.TableRefreshUtils; import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; @@ -59,6 +60,7 @@ /** * Standalone mode context manager. */ +@Setter public final class StandaloneModeContextManager implements ModeContextManager, ContextManagerAware { private final RuleConfigurationEventBuilder ruleConfigurationEventBuilder = new RuleConfigurationEventBuilder(); @@ -318,9 +320,4 @@ public void alterProperties(final Properties props) { private void clearServiceCache() { OrderedServicesCache.clearCache(); } - - @Override - public void setContextManagerAware(final ContextManager contextManager) { - this.contextManager = contextManager; - } } diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutorTest.java index c3ec0c8322e83..bb6d9e6b9cf89 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableExecutorTest.java @@ -112,7 +112,7 @@ private ContextManager mockContextManager() { ContextManager result = new ContextManager(new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData()), new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), mock(WorkerIdGenerator.class), new ModeConfiguration("Standalone", null), standaloneModeContextManager, mock(LockContext.class), new EventBusContext())); - standaloneModeContextManager.setContextManagerAware(result); + standaloneModeContextManager.setContextManager(result); return result; } }