Skip to content

Commit e07b83e

Browse files
committed
Refactor ContextManager
1 parent 59c0a77 commit e07b83e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ public ContextManager(final MetaDataContexts metaDataContexts, final ComputeNode
8080
persistServiceFacade = new PersistServiceFacade(repository, computeNodeInstanceContext.getModeConfiguration(), metaDataContextManager);
8181
stateContext = new StateContext(persistServiceFacade.getStateService().load());
8282
executorEngine = ExecutorEngine.createExecutorEngineWithSize(metaDataContexts.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE));
83-
for (ContextManagerLifecycleListener each : ShardingSphereServiceLoader.getServiceInstances(ContextManagerLifecycleListener.class)) {
84-
if (computeNodeInstanceContext.getModeConfiguration().isCluster()) {
85-
each.onInitialized(this);
86-
}
83+
if (computeNodeInstanceContext.getModeConfiguration().isCluster()) {
84+
ShardingSphereServiceLoader.getServiceInstances(ContextManagerLifecycleListener.class).forEach(each -> each.onInitialized(this));
8785
}
8886
}
8987

@@ -233,8 +231,8 @@ public String getPreSelectedDatabaseName() {
233231

234232
@Override
235233
public void close() {
236-
for (ContextManagerLifecycleListener each : ShardingSphereServiceLoader.getServiceInstances(ContextManagerLifecycleListener.class)) {
237-
each.onDestroyed(this);
234+
if (computeNodeInstanceContext.getModeConfiguration().isCluster()) {
235+
ShardingSphereServiceLoader.getServiceInstances(ContextManagerLifecycleListener.class).forEach(each -> each.onDestroyed(this));
238236
}
239237
executorEngine.close();
240238
metaDataContexts.getMetaData().close();

0 commit comments

Comments
 (0)