Show compute nodes from repository (#34371)
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 9493c1e..81ae33c 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 @@
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 75e8339..947b9dc 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 @@
@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 @@
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 @@
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;
}
}