Skip to content

Commit 7ffbdca

Browse files
authored
Show compute nodes from repository (#34371)
1 parent 32b1aa7 commit 7ffbdca

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public Collection<LocalDataQueryResultRow> getRows(final ShowComputeNodesStateme
4545
String modeType = contextManager.getComputeNodeInstanceContext().getModeConfiguration().getType();
4646
return "Standalone".equals(modeType)
4747
? Collections.singleton(buildRow(contextManager.getComputeNodeInstanceContext().getInstance(), modeType))
48-
: contextManager.getComputeNodeInstanceContext().getClusterInstanceRegistry().getAllClusterInstances().stream().map(each -> buildRow(each, modeType)).collect(Collectors.toList());
48+
: contextManager.getPersistServiceFacade().getComputeNodePersistService().loadAllInstances().stream().map(each -> buildRow(each, modeType)).collect(Collectors.toList());
4949
}
5050

5151
private LocalDataQueryResultRow buildRow(final ComputeNodeInstance instance, final String modeType) {

proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutorTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ void assertExecuteWithStandaloneMode() {
6565
@Test
6666
void assertExecuteWithClusterMode() {
6767
ShowComputeNodesExecutor executor = new ShowComputeNodesExecutor();
68-
ContextManager contextManager = mock(ContextManager.class);
69-
ComputeNodeInstanceContext computeNodeInstanceContext = createClusterInstanceContext();
68+
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
69+
ComputeNodeInstanceContext computeNodeInstanceContext = createClusterInstanceContext(contextManager);
7070
when(contextManager.getComputeNodeInstanceContext()).thenReturn(computeNodeInstanceContext);
7171
Collection<LocalDataQueryResultRow> actual = executor.getRows(mock(ShowComputeNodesStatement.class), contextManager);
7272
assertThat(actual.size(), is(1));
@@ -92,14 +92,15 @@ private ComputeNodeInstanceContext createStandaloneInstanceContext() {
9292
return result;
9393
}
9494

95-
private ComputeNodeInstanceContext createClusterInstanceContext() {
95+
private ComputeNodeInstanceContext createClusterInstanceContext(final ContextManager contextManager) {
9696
ComputeNodeInstanceContext result = mock(ComputeNodeInstanceContext.class, RETURNS_DEEP_STUBS);
9797
when(result.getModeConfiguration()).thenReturn(new ModeConfiguration("Cluster", mock(PersistRepositoryConfiguration.class)));
9898
ComputeNodeInstance computeNodeInstance = mock(ComputeNodeInstance.class, RETURNS_DEEP_STUBS);
9999
when(computeNodeInstance.getMetaData()).thenReturn(new ProxyInstanceMetaData("foo", "127.0.0.1@3309", "foo_version"));
100100
when(computeNodeInstance.getState()).thenReturn(new InstanceStateContext());
101101
when(computeNodeInstance.getWorkerId()).thenReturn(1);
102102
when(result.getClusterInstanceRegistry().getAllClusterInstances()).thenReturn(Collections.singleton(computeNodeInstance));
103+
when(contextManager.getPersistServiceFacade().getComputeNodePersistService().loadAllInstances()).thenReturn(Collections.singleton(computeNodeInstance));
103104
return result;
104105
}
105106
}

0 commit comments

Comments
 (0)