Skip to content

Commit

Permalink
Rename ContextManagerAware.setContextManager() (#31219)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored May 12, 2024
1 parent d6e24f0 commit 3018c65
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,6 +43,7 @@
/**
* Cluster mode context manager.
*/
@Setter
public final class ClusterModeContextManager implements ModeContextManager, ContextManagerAware {

private ContextManager contextManager;
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,6 +60,7 @@
/**
* Standalone mode context manager.
*/
@Setter
public final class StandaloneModeContextManager implements ModeContextManager, ContextManagerAware {

private final RuleConfigurationEventBuilder ruleConfigurationEventBuilder = new RuleConfigurationEventBuilder();
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 3018c65

Please sign in to comment.