From dea4eac73faf7d5d5a9d7a946257f983be6e2c91 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Wed, 22 May 2024 00:05:56 +0800 Subject: [PATCH] Refactor ClusterContextManagerBuilder (#31335) --- .../mode/manager/cluster/ClusterContextManagerBuilder.java | 5 +++-- 1 file changed, 3 insertions(+), 2 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 b478531f2a3d4..89e189e630950 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 @@ -112,13 +112,14 @@ private void createSubscribers(final EventBusContext eventBusContext, final Clus private void registerOnline(final EventBusContext eventBusContext, final ComputeNodeInstanceContext computeNodeInstanceContext, final ClusterPersistRepository repository, final ContextManagerBuilderParameter param, final ContextManager contextManager) { - new ComputeNodeStatusService(repository).registerOnline(computeNodeInstanceContext.getInstance()); + ComputeNodeStatusService computeNodeStatusService = new ComputeNodeStatusService(repository); + computeNodeStatusService.registerOnline(computeNodeInstanceContext.getInstance()); new GovernanceWatcherFactory(repository, eventBusContext, param.getInstanceMetaData() instanceof JDBCInstanceMetaData ? param.getDatabaseConfigs().keySet() : Collections.emptyList()).watchListeners(); if (null != param.getLabels()) { contextManager.getComputeNodeInstanceContext().getInstance().getLabels().addAll(param.getLabels()); } - contextManager.getComputeNodeInstanceContext().getAllClusterInstances().addAll(new ComputeNodeStatusService(repository).loadAllComputeNodeInstances()); + contextManager.getComputeNodeInstanceContext().getAllClusterInstances().addAll(computeNodeStatusService.loadAllComputeNodeInstances()); new ClusterEventSubscriberRegistry(contextManager, repository).register(); }