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 ed015b19752 Refactor StandaloneWorkerIdGenerator (#31316)
ed015b19752 is described below

commit ed015b1975210499c7df342c11a285c90b0503a2
Author: Liang Zhang <[email protected]>
AuthorDate: Mon May 20 23:04:32 2024 +0800

    Refactor StandaloneWorkerIdGenerator (#31316)
---
 .../infra/instance/ComputeNodeInstance.java        | 10 ++++-----
 .../infra/instance/ComputeNodeInstanceContext.java | 24 ++++++++++++----------
 .../infra/instance/workerid/WorkerIdGenerator.java |  6 ++----
 .../infra/state/instance/InstanceState.java        |  3 ++-
 .../DriverDatabaseConnectionManager.java           |  2 +-
 .../DriverDatabaseConnectionManagerTest.java       |  2 +-
 .../traffic/engine/TrafficEngine.java              |  2 +-
 .../algorithm/engine/TrafficEngineTest.java        |  2 +-
 .../cluster/ClusterContextManagerBuilder.java      |  2 +-
 .../subscriber/StateChangedSubscriberTest.java     | 12 +++++------
 .../generator/StandaloneWorkerIdGenerator.java     | 10 ++++-----
 .../generator/StandaloneWorkerIdGeneratorTest.java |  7 +------
 .../ral/queryable/ShowComputeNodesExecutor.java    |  2 +-
 .../queryable/ShowComputeNodesExecutorTest.java    |  2 +-
 14 files changed, 40 insertions(+), 46 deletions(-)

diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstance.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstance.java
index b04e29743da..9725f0ec8ce 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstance.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstance.java
@@ -48,13 +48,13 @@ public final class ComputeNodeInstance {
     /**
      * Switch state.
      *
-     * @param instanceState instance state
+     * @param state instance state
      */
-    public void switchState(final InstanceState instanceState) {
-        if (InstanceState.CIRCUIT_BREAK == instanceState) {
-            state.switchState(instanceState);
+    public void switchState(final InstanceState state) {
+        if (InstanceState.CIRCUIT_BREAK == state) {
+            this.state.switchState(state);
         } else {
-            state.recoverState(InstanceState.CIRCUIT_BREAK);
+            this.state.recoverState(InstanceState.CIRCUIT_BREAK);
         }
     }
 }
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContext.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContext.java
index 0b04c5f41e2..9a11cc5f3f1 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContext.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContext.java
@@ -29,6 +29,7 @@ import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.infra.state.instance.InstanceState;
 import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
 
+import javax.annotation.concurrent.ThreadSafe;
 import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -41,6 +42,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
  */
 @RequiredArgsConstructor
 @Getter
+@ThreadSafe
 public final class ComputeNodeInstanceContext {
     
     private final ComputeNodeInstance instance;
@@ -57,7 +59,7 @@ public final class ComputeNodeInstanceContext {
     
     private final EventBusContext eventBusContext;
     
-    private final Collection<ComputeNodeInstance> 
allClusterComputeNodeInstances = new CopyOnWriteArrayList<>();
+    private final Collection<ComputeNodeInstance> allClusterInstances = new 
CopyOnWriteArrayList<>();
     
     /**
      * Update instance status.
@@ -77,7 +79,7 @@ public final class ComputeNodeInstanceContext {
     }
     
     private void updateRelatedComputeNodeInstancesStatus(final String 
instanceId, final InstanceState instanceState) {
-        for (ComputeNodeInstance each : allClusterComputeNodeInstances) {
+        for (ComputeNodeInstance each : allClusterInstances) {
             if (each.getMetaData().getId().equals(instanceId)) {
                 each.switchState(instanceState);
             }
@@ -94,7 +96,7 @@ public final class ComputeNodeInstanceContext {
         if (instance.getMetaData().getId().equals(instanceId)) {
             instance.setWorkerId(workerId);
         }
-        allClusterComputeNodeInstances.stream().filter(each -> 
each.getMetaData().getId().equals(instanceId)).forEach(each -> 
each.setWorkerId(workerId));
+        allClusterInstances.stream().filter(each -> 
each.getMetaData().getId().equals(instanceId)).forEach(each -> 
each.setWorkerId(workerId));
     }
     
     /**
@@ -108,7 +110,7 @@ public final class ComputeNodeInstanceContext {
             instance.getLabels().clear();
             instance.getLabels().addAll(labels);
         }
-        for (ComputeNodeInstance each : allClusterComputeNodeInstances) {
+        for (ComputeNodeInstance each : allClusterInstances) {
             if (each.getMetaData().getId().equals(instanceId)) {
                 each.getLabels().clear();
                 each.getLabels().addAll(labels);
@@ -143,8 +145,8 @@ public final class ComputeNodeInstanceContext {
      * @param instance compute node instance
      */
     public void addComputeNodeInstance(final ComputeNodeInstance instance) {
-        allClusterComputeNodeInstances.removeIf(each -> 
each.getMetaData().getId().equalsIgnoreCase(instance.getMetaData().getId()));
-        allClusterComputeNodeInstances.add(instance);
+        allClusterInstances.removeIf(each -> 
each.getMetaData().getId().equalsIgnoreCase(instance.getMetaData().getId()));
+        allClusterInstances.add(instance);
     }
     
     /**
@@ -153,7 +155,7 @@ public final class ComputeNodeInstanceContext {
      * @param instance compute node instance
      */
     public void deleteComputeNodeInstance(final ComputeNodeInstance instance) {
-        allClusterComputeNodeInstances.removeIf(each -> 
each.getMetaData().getId().equalsIgnoreCase(instance.getMetaData().getId()));
+        allClusterInstances.removeIf(each -> 
each.getMetaData().getId().equalsIgnoreCase(instance.getMetaData().getId()));
     }
     
     /**
@@ -163,9 +165,9 @@ public final class ComputeNodeInstanceContext {
      * @param labels collection of contained label
      * @return compute node instances
      */
-    public Map<String, InstanceMetaData> 
getAllClusterComputeNodeInstances(final InstanceType instanceType, final 
Collection<String> labels) {
-        Map<String, InstanceMetaData> result = new 
LinkedHashMap<>(allClusterComputeNodeInstances.size(), 1F);
-        for (ComputeNodeInstance each : allClusterComputeNodeInstances) {
+    public Map<String, InstanceMetaData> getAllClusterInstances(final 
InstanceType instanceType, final Collection<String> labels) {
+        Map<String, InstanceMetaData> result = new 
LinkedHashMap<>(allClusterInstances.size(), 1F);
+        for (ComputeNodeInstance each : allClusterInstances) {
             if (each.getMetaData().getType() == instanceType && 
labels.stream().anyMatch(((Collection<String>) each.getLabels())::contains)) {
                 result.put(each.getMetaData().getId(), each.getMetaData());
             }
@@ -180,7 +182,7 @@ public final class ComputeNodeInstanceContext {
      * @return compute node instance
      */
     public Optional<ComputeNodeInstance> getComputeNodeInstanceById(final 
String instanceId) {
-        return allClusterComputeNodeInstances.stream().filter(each -> 
instanceId.equals(each.getMetaData().getId())).findFirst();
+        return allClusterInstances.stream().filter(each -> 
instanceId.equals(each.getMetaData().getId())).findFirst();
     }
     
     /**
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/workerid/WorkerIdGenerator.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/workerid/WorkerIdGenerator.java
index bc6681cced5..03c25011019 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/workerid/WorkerIdGenerator.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/workerid/WorkerIdGenerator.java
@@ -26,15 +26,13 @@ public interface WorkerIdGenerator {
     
     String WORKER_ID_KEY = "worker-id";
     
-    int DEFAULT_WORKER_ID = 0;
-    
     int MAX_WORKER_ID = 1023;
     
     /**
-     * Generate worker id.
+     * Generate worker ID.
      *
      * @param props props
-     * @return worker id
+     * @return worker ID
      */
     int generate(Properties props);
 }
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/state/instance/InstanceState.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/state/instance/InstanceState.java
index a6f4a30648b..8942898b0cb 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/state/instance/InstanceState.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/state/instance/InstanceState.java
@@ -35,7 +35,8 @@ public enum InstanceState {
     public static Optional<InstanceState> get(final String state) {
         if (OK.name().equals(state)) {
             return Optional.of(OK);
-        } else if (CIRCUIT_BREAK.name().equals(state)) {
+        }
+        if (CIRCUIT_BREAK.name().equals(state)) {
             return Optional.of(CIRCUIT_BREAK);
         }
         return Optional.empty();
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
index f066de9a844..85e675c4cb3 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
@@ -116,7 +116,7 @@ public final class DriverDatabaseConnectionManager 
implements OnlineDatabaseConn
         DataSourcePoolProperties propsSample = 
propsMap.values().iterator().next();
         Collection<ShardingSphereUser> users = 
contextManager.getMetaDataContexts().getMetaData()
                 
.getGlobalRuleMetaData().getSingleRule(AuthorityRule.class).getConfiguration().getUsers();
-        Collection<InstanceMetaData> instances = 
contextManager.getComputeNodeInstanceContext().getAllClusterComputeNodeInstances(InstanceType.PROXY,
 rule.getLabels()).values();
+        Collection<InstanceMetaData> instances = 
contextManager.getComputeNodeInstanceContext().getAllClusterInstances(InstanceType.PROXY,
 rule.getLabels()).values();
         return 
DataSourcePoolCreator.create(createDataSourcePoolPropertiesMap(instances, 
users, propsSample, actualDatabaseName), true);
     }
     
diff --git 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
index 92a31e2d2c7..a611dc0e633 100644
--- 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
+++ 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
@@ -82,7 +82,7 @@ class DriverDatabaseConnectionManagerTest {
         
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(
                 new RuleMetaData(Arrays.asList(mock(AuthorityRule.class, 
RETURNS_DEEP_STUBS), mock(TransactionRule.class, RETURNS_DEEP_STUBS),
                         mock(TrafficRule.class, RETURNS_DEEP_STUBS))));
-        
when(result.getComputeNodeInstanceContext().getAllClusterComputeNodeInstances(InstanceType.PROXY,
 Arrays.asList("OLTP", "OLAP"))).thenReturn(
+        
when(result.getComputeNodeInstanceContext().getAllClusterInstances(InstanceType.PROXY,
 Arrays.asList("OLTP", "OLAP"))).thenReturn(
                 Collections.singletonMap("foo_id", new 
ProxyInstanceMetaData("foo_id", "127.0.0.1@3307", "foo_version")));
         Map<String, DataSource> trafficDataSourceMap = 
mockTrafficDataSourceMap();
         when(DataSourcePoolCreator.create(any(), 
eq(true))).thenReturn(trafficDataSourceMap);
diff --git 
a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/engine/TrafficEngine.java
 
b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/engine/TrafficEngine.java
index 75555b0e021..d4e35cf5481 100644
--- 
a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/engine/TrafficEngine.java
+++ 
b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/engine/TrafficEngine.java
@@ -52,7 +52,7 @@ public final class TrafficEngine {
         if (!strategyRule.isPresent() || 
isInvalidStrategyRule(strategyRule.get())) {
             return Optional.empty();
         }
-        Map<String, InstanceMetaData> instances = 
computeNodeInstanceContext.getAllClusterComputeNodeInstances(InstanceType.PROXY,
 strategyRule.get().getLabels());
+        Map<String, InstanceMetaData> instances = 
computeNodeInstanceContext.getAllClusterInstances(InstanceType.PROXY, 
strategyRule.get().getLabels());
         if (!instances.isEmpty()) {
             LoadBalanceAlgorithm loadBalancer = 
strategyRule.get().getLoadBalancer();
             String instanceId = 1 == instances.size() ? 
instances.keySet().iterator().next() : 
loadBalancer.getTargetName(strategyRule.get().getName(), new 
ArrayList<>(instances.keySet()));
diff --git 
a/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/algorithm/engine/TrafficEngineTest.java
 
b/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/algorithm/engine/TrafficEngineTest.java
index 20e4108a71c..6b1aec7a433 100644
--- 
a/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/algorithm/engine/TrafficEngineTest.java
+++ 
b/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/algorithm/engine/TrafficEngineTest.java
@@ -96,7 +96,7 @@ class TrafficEngineTest {
         when(loadBalancer.getTargetName("traffic", new 
ArrayList<>(instanceIds.keySet()))).thenReturn("foo_id");
         when(strategyRule.getLoadBalancer()).thenReturn(loadBalancer);
         when(strategyRule.getName()).thenReturn("traffic");
-        
when(computeNodeInstanceContext.getAllClusterComputeNodeInstances(InstanceType.PROXY,
 Arrays.asList("OLTP", "OLAP"))).thenReturn(instanceIds);
+        
when(computeNodeInstanceContext.getAllClusterInstances(InstanceType.PROXY, 
Arrays.asList("OLTP", "OLAP"))).thenReturn(instanceIds);
         Optional<String> actual = trafficEngine.dispatch(queryContext, false);
         assertThat(actual, is(Optional.of("foo_id")));
     }
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 959e636be33..b4848001fe4 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
@@ -120,7 +120,7 @@ public final class ClusterContextManagerBuilder implements 
ContextManagerBuilder
         if (null != param.getLabels()) {
             
contextManager.getComputeNodeInstanceContext().getInstance().getLabels().addAll(param.getLabels());
         }
-        
contextManager.getComputeNodeInstanceContext().getAllClusterComputeNodeInstances().addAll(new
 ComputeNodeStatusService(repository).loadAllComputeNodeInstances());
+        
contextManager.getComputeNodeInstanceContext().getAllClusterInstances().addAll(new
 ComputeNodeStatusService(repository).loadAllComputeNodeInstances());
         new ClusterEventSubscriberRegistry(contextManager, 
repository).register();
     }
     
diff --git 
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java
 
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java
index c412cd7b583..e21afb5cbfb 100644
--- 
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java
+++ 
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java
@@ -167,15 +167,15 @@ class StateChangedSubscriberTest {
         InstanceMetaData instanceMetaData1 = new 
ProxyInstanceMetaData("foo_instance_3307", 3307);
         InstanceOnlineEvent instanceOnlineEvent1 = new 
InstanceOnlineEvent(instanceMetaData1);
         subscriber.renew(instanceOnlineEvent1);
-        
assertThat(contextManager.getComputeNodeInstanceContext().getAllClusterComputeNodeInstances().size(),
 is(1));
-        assertThat(((CopyOnWriteArrayList<ComputeNodeInstance>) 
contextManager.getComputeNodeInstanceContext().getAllClusterComputeNodeInstances()).get(0).getMetaData(),
 is(instanceMetaData1));
+        
assertThat(contextManager.getComputeNodeInstanceContext().getAllClusterInstances().size(),
 is(1));
+        assertThat(((CopyOnWriteArrayList<ComputeNodeInstance>) 
contextManager.getComputeNodeInstanceContext().getAllClusterInstances()).get(0).getMetaData(),
 is(instanceMetaData1));
         InstanceMetaData instanceMetaData2 = new 
ProxyInstanceMetaData("foo_instance_3308", 3308);
         InstanceOnlineEvent instanceOnlineEvent2 = new 
InstanceOnlineEvent(instanceMetaData2);
         subscriber.renew(instanceOnlineEvent2);
-        
assertThat(contextManager.getComputeNodeInstanceContext().getAllClusterComputeNodeInstances().size(),
 is(2));
-        assertThat(((CopyOnWriteArrayList<ComputeNodeInstance>) 
contextManager.getComputeNodeInstanceContext().getAllClusterComputeNodeInstances()).get(1).getMetaData(),
 is(instanceMetaData2));
+        
assertThat(contextManager.getComputeNodeInstanceContext().getAllClusterInstances().size(),
 is(2));
+        assertThat(((CopyOnWriteArrayList<ComputeNodeInstance>) 
contextManager.getComputeNodeInstanceContext().getAllClusterInstances()).get(1).getMetaData(),
 is(instanceMetaData2));
         subscriber.renew(instanceOnlineEvent1);
-        
assertThat(contextManager.getComputeNodeInstanceContext().getAllClusterComputeNodeInstances().size(),
 is(2));
-        assertThat(((CopyOnWriteArrayList<ComputeNodeInstance>) 
contextManager.getComputeNodeInstanceContext().getAllClusterComputeNodeInstances()).get(1).getMetaData(),
 is(instanceMetaData1));
+        
assertThat(contextManager.getComputeNodeInstanceContext().getAllClusterInstances().size(),
 is(2));
+        assertThat(((CopyOnWriteArrayList<ComputeNodeInstance>) 
contextManager.getComputeNodeInstanceContext().getAllClusterInstances()).get(1).getMetaData(),
 is(instanceMetaData1));
     }
 }
diff --git 
a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/workerid/generator/StandaloneWorkerIdGenerator.java
 
b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/workerid/generator/StandaloneWorkerIdGenerator.java
index 6030c1de961..8af9297454a 100644
--- 
a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/workerid/generator/StandaloneWorkerIdGenerator.java
+++ 
b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/workerid/generator/StandaloneWorkerIdGenerator.java
@@ -27,16 +27,14 @@ import java.util.Properties;
  */
 public final class StandaloneWorkerIdGenerator implements WorkerIdGenerator {
     
+    private static final int DEFAULT_WORKER_ID = 0;
+    
     @Override
     public int generate(final Properties props) {
-        if (null == props) {
-            return DEFAULT_WORKER_ID;
-        }
-        Object workerId = props.get(WORKER_ID_KEY);
-        if (null == workerId) {
+        if (!props.containsKey(WORKER_ID_KEY)) {
             return DEFAULT_WORKER_ID;
         }
-        int result = Integer.parseInt(workerId.toString());
+        int result = Integer.parseInt(props.get(WORKER_ID_KEY).toString());
         Preconditions.checkState(result <= MAX_WORKER_ID, "%s can not exceed 
%s", WORKER_ID_KEY, MAX_WORKER_ID);
         return result;
     }
diff --git 
a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/workerid/generator/StandaloneWorkerIdGeneratorTest.java
 
b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/workerid/generator/StandaloneWorkerIdGeneratorTest.java
index 775b8436caa..625e993d403 100644
--- 
a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/workerid/generator/StandaloneWorkerIdGeneratorTest.java
+++ 
b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/workerid/generator/StandaloneWorkerIdGeneratorTest.java
@@ -30,14 +30,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 
 class StandaloneWorkerIdGeneratorTest {
     
-    @Test
-    void assertGenerateWithNullProperties() {
-        assertThat(new StandaloneWorkerIdGenerator().generate(null), 
is(WorkerIdGenerator.DEFAULT_WORKER_ID));
-    }
-    
     @Test
     void assertGenerateWithEmptyProperties() {
-        assertThat(new StandaloneWorkerIdGenerator().generate(new 
Properties()), is(WorkerIdGenerator.DEFAULT_WORKER_ID));
+        assertThat(new StandaloneWorkerIdGenerator().generate(new 
Properties()), is(0));
     }
     
     @Test
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java
index 3ea02398980..b833a9eddbf 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java
@@ -45,7 +45,7 @@ public final class ShowComputeNodesExecutor implements 
DistSQLQueryExecutor<Show
         String modeType = 
contextManager.getComputeNodeInstanceContext().getModeConfiguration().getType();
         return "Standalone".equals(modeType)
                 ? 
Collections.singleton(buildRow(contextManager.getComputeNodeInstanceContext().getInstance(),
 modeType))
-                : 
contextManager.getComputeNodeInstanceContext().getAllClusterComputeNodeInstances().stream().map(each
 -> buildRow(each, modeType)).collect(Collectors.toList());
+                : 
contextManager.getComputeNodeInstanceContext().getAllClusterInstances().stream().map(each
 -> buildRow(each, modeType)).collect(Collectors.toList());
     }
     
     private LocalDataQueryResultRow buildRow(final ComputeNodeInstance 
instance, final String modeType) {
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutorTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutorTest.java
index 07c16d1d5a7..699683dd202 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutorTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutorTest.java
@@ -97,7 +97,7 @@ class ShowComputeNodesExecutorTest {
         when(computeNodeInstance.getMetaData()).thenReturn(new 
ProxyInstanceMetaData("foo", "127.0.0.1@3309", "foo_version"));
         when(computeNodeInstance.getState()).thenReturn(new 
InstanceStateContext());
         when(computeNodeInstance.getWorkerId()).thenReturn(1);
-        
when(result.getAllClusterComputeNodeInstances()).thenReturn(Collections.singleton(computeNodeInstance));
+        
when(result.getAllClusterInstances()).thenReturn(Collections.singleton(computeNodeInstance));
         return result;
     }
 }

Reply via email to