Skip to content

Commit b16801a

Browse files
alaturquaebyhr
authored andcommitted
cleanup monitorType JMX
1 parent 3a82b83 commit b16801a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public class ClusterStatsJmxMonitor
4242
private static final JsonResponseHandler<JsonNode> JMX_JSON_RESPONSE_HANDLER = createJsonResponseHandler(jsonCodec(JsonNode.class));
4343
private static final String JMX_PATH = "/v1/jmx/mbean";
4444

45+
private final HttpClient client;
4546
private final String username;
4647
private final String password;
47-
private final HttpClient client;
4848

4949
public ClusterStatsJmxMonitor(HttpClient client, BackendStateConfiguration backendStateConfiguration)
5050
{
@@ -88,7 +88,7 @@ private static void updateClusterStatsFromQueryManagerResponse(JmxResponse respo
8888
int runningQueryCount = stats.getOrDefault("RunningQueries", 0);
8989
clusterStats.runningQueryCount(runningQueryCount);
9090

91-
log.debug(String.format("Processed QueryManager: QueuedQueries = %d, RunningQueries = %d", queuedQueryCount, runningQueryCount));
91+
log.debug("Processed QueryManager: QueuedQueries = %d, RunningQueries = %d", queuedQueryCount, runningQueryCount);
9292
}
9393
catch (Exception e) {
9494
log.error(e, "Error parsing QueryManager stats");
@@ -144,7 +144,7 @@ private Optional<JmxResponse> queryJmx(ProxyBackendConfiguration backend, String
144144

145145
try {
146146
JsonNode response = client.execute(preparedRequest, JMX_JSON_RESPONSE_HANDLER);
147-
return Optional.ofNullable(response).map(JmxResponse::fromJson);
147+
return Optional.of(response).map(JmxResponse::fromJson);
148148
}
149149
catch (UnexpectedResponseException e) {
150150
log.error(e, "Failed to fetch JMX data for %s, response code: %d", mbeanName, e.getStatusCode());

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void testJmxMonitor()
8080
@Test
8181
void testJmxMonitorWithBadRequest()
8282
{
83-
HttpClient client = new TestingHttpClient(ignored -> TestingResponse
83+
HttpClient client = new TestingHttpClient(_ -> TestingResponse
8484
.mockResponse(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8, "Bad Request"));
8585

8686
testClusterStatsMonitorWithClient(client);
@@ -89,7 +89,7 @@ void testJmxMonitorWithBadRequest()
8989
@Test
9090
void testJmxMonitorWithServerError()
9191
{
92-
HttpClient client = new TestingHttpClient(ignored -> TestingResponse
92+
HttpClient client = new TestingHttpClient(_ -> TestingResponse
9393
.mockResponse(HttpStatus.INTERNAL_SERVER_ERROR, MediaType.PLAIN_TEXT_UTF_8, "Internal Server Error"));
9494

9595
testClusterStatsMonitorWithClient(client);
@@ -98,7 +98,7 @@ void testJmxMonitorWithServerError()
9898
@Test
9999
void testJmxMonitorWithInvalidJson()
100100
{
101-
HttpClient client = new TestingHttpClient(ignored -> TestingResponse
101+
HttpClient client = new TestingHttpClient(_ -> TestingResponse
102102
.mockResponse(HttpStatus.OK, MediaType.JSON_UTF_8, "{invalid:json}"));
103103

104104
testClusterStatsMonitorWithClient(client);
@@ -107,7 +107,7 @@ void testJmxMonitorWithInvalidJson()
107107
@Test
108108
void testJmxMonitorWithNetworkError()
109109
{
110-
HttpClient client = new TestingHttpClient(ignored -> {
110+
HttpClient client = new TestingHttpClient(_ -> {
111111
throw new RuntimeException("Network error");
112112
});
113113

@@ -133,8 +133,8 @@ void testInfoApiMonitor()
133133
{
134134
MonitorConfiguration monitorConfigurationWithRetries = new MonitorConfiguration();
135135
monitorConfigurationWithRetries.setRetries(10);
136-
testClusterStatsMonitor(ignored -> new ClusterStatsInfoApiMonitor(new JettyHttpClient(new HttpClientConfig()), new MonitorConfiguration()));
137-
testClusterStatsMonitor(ignored -> new ClusterStatsInfoApiMonitor(new JettyHttpClient(new HttpClientConfig()), monitorConfigurationWithRetries));
136+
testClusterStatsMonitor(_ -> new ClusterStatsInfoApiMonitor(new JettyHttpClient(new HttpClientConfig()), new MonitorConfiguration()));
137+
testClusterStatsMonitor(_ -> new ClusterStatsInfoApiMonitor(new JettyHttpClient(new HttpClientConfig()), monitorConfigurationWithRetries));
138138
}
139139

140140
private void testClusterStatsMonitor(Function<BackendStateConfiguration, ClusterStatsMonitor> monitorFactory)

0 commit comments

Comments
 (0)