You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2025/01/16 10:19:03 UTC

(shardingsphere) branch master updated: Show compute nodes from repository (#34371)

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 7ffbdca1322 Show compute nodes from repository (#34371)
7ffbdca1322 is described below

commit 7ffbdca1322793e912184beea2f23e15ce4efd8a
Author: Haoran Meng <me...@gmail.com>
AuthorDate: Thu Jan 16 18:18:57 2025 +0800

    Show compute nodes from repository (#34371)
---
 .../handler/distsql/ral/queryable/ShowComputeNodesExecutor.java    | 2 +-
 .../distsql/ral/queryable/ShowComputeNodesExecutorTest.java        | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

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 9493c1e4af3..81ae33c8769 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().getClusterInstanceRegistry().getAllClusterInstances().stream().map(each -> buildRow(each, modeType)).collect(Collectors.toList());
+                : contextManager.getPersistServiceFacade().getComputeNodePersistService().loadAllInstances().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 75e83399b22..947b9dcfda5 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
@@ -65,8 +65,8 @@ class ShowComputeNodesExecutorTest {
     @Test
     void assertExecuteWithClusterMode() {
         ShowComputeNodesExecutor executor = new ShowComputeNodesExecutor();
-        ContextManager contextManager = mock(ContextManager.class);
-        ComputeNodeInstanceContext computeNodeInstanceContext = createClusterInstanceContext();
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ComputeNodeInstanceContext computeNodeInstanceContext = createClusterInstanceContext(contextManager);
         when(contextManager.getComputeNodeInstanceContext()).thenReturn(computeNodeInstanceContext);
         Collection<LocalDataQueryResultRow> actual = executor.getRows(mock(ShowComputeNodesStatement.class), contextManager);
         assertThat(actual.size(), is(1));
@@ -92,7 +92,7 @@ class ShowComputeNodesExecutorTest {
         return result;
     }
     
-    private ComputeNodeInstanceContext createClusterInstanceContext() {
+    private ComputeNodeInstanceContext createClusterInstanceContext(final ContextManager contextManager) {
         ComputeNodeInstanceContext result = mock(ComputeNodeInstanceContext.class, RETURNS_DEEP_STUBS);
         when(result.getModeConfiguration()).thenReturn(new ModeConfiguration("Cluster", mock(PersistRepositoryConfiguration.class)));
         ComputeNodeInstance computeNodeInstance = mock(ComputeNodeInstance.class, RETURNS_DEEP_STUBS);
@@ -100,6 +100,7 @@ class ShowComputeNodesExecutorTest {
         when(computeNodeInstance.getState()).thenReturn(new InstanceStateContext());
         when(computeNodeInstance.getWorkerId()).thenReturn(1);
         when(result.getClusterInstanceRegistry().getAllClusterInstances()).thenReturn(Collections.singleton(computeNodeInstance));
+        when(contextManager.getPersistServiceFacade().getComputeNodePersistService().loadAllInstances()).thenReturn(Collections.singleton(computeNodeInstance));
         return result;
     }
 }