Skip to content

Commit 8cb4d03

Browse files
committed
Treat all backends as alive in Noop monitor
1 parent c580816 commit 8cb4d03

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

gateway-ha/src/main/java/io/trino/gateway/ha/clustermonitor/NoopClusterStatsMonitor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public class NoopClusterStatsMonitor
2121
@Override
2222
public ClusterStats monitor(ProxyBackendConfiguration backend)
2323
{
24-
return ClusterStats.builder(backend.getName()).build();
24+
return ClusterStats.builder(backend.getName())
25+
.trinoStatus(TrinoStatus.HEALTHY)
26+
.proxyTo(backend.getProxyTo())
27+
.externalUrl(backend.getExternalUrl())
28+
.routingGroup(backend.getRoutingGroup())
29+
.build();
2530
}
2631
}

gateway-ha/src/test/java/io/trino/gateway/ha/clustermonitor/TestClusterStatsMonitor.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ void testJmxMonitor()
7979
testClusterStatsMonitor(backendStateConfiguration -> new ClusterStatsJmxMonitor(new JettyHttpClient(new HttpClientConfig()), backendStateConfiguration));
8080
}
8181

82+
@Test
83+
void testNoopMonitor()
84+
{
85+
ClusterStatsMonitor monitor = new NoopClusterStatsMonitor();
86+
ProxyBackendConfiguration proxyBackend = new ProxyBackendConfiguration();
87+
proxyBackend.setProxyTo("http://localhost:61234"); // assume no service running on this port
88+
proxyBackend.setName("test_cluster");
89+
90+
ClusterStats stats = monitor.monitor(proxyBackend);
91+
assertThat(stats.clusterId()).isEqualTo("test_cluster");
92+
assertThat(stats.trinoStatus()).isEqualTo(TrinoStatus.HEALTHY);
93+
}
94+
8295
@Test
8396
void testJmxMonitorWithBadRequest()
8497
{

0 commit comments

Comments
 (0)