Skip to content

Commit 1acf39d

Browse files
committed
fixed test by calling ping so pool is initialized
1 parent a0e043e commit 1acf39d

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

client-v2/src/main/java/com/clickhouse/client/api/Client.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,22 @@ public class Client implements AutoCloseable {
141141

142142
// Server context
143143
private String serverVersion;
144-
private Object metrics;
144+
private Object metricsRegistry;
145145

146146
private Client(Set<String> endpoints, Map<String,String> configuration, boolean useNewImplementation,
147147
ExecutorService sharedOperationExecutor, ColumnToMethodMatchingStrategy columnToMethodMatchingStrategy) {
148148
this(endpoints, configuration, useNewImplementation, sharedOperationExecutor, columnToMethodMatchingStrategy, null);
149149
}
150150

151151
private Client(Set<String> endpoints, Map<String,String> configuration, boolean useNewImplementation,
152-
ExecutorService sharedOperationExecutor, ColumnToMethodMatchingStrategy columnToMethodMatchingStrategy, Object metrics) {
152+
ExecutorService sharedOperationExecutor, ColumnToMethodMatchingStrategy columnToMethodMatchingStrategy, Object metricsRegistry) {
153153
this.endpoints = endpoints;
154154
this.configuration = configuration;
155155
this.readOnlyConfig = Collections.unmodifiableMap(this.configuration);
156156
this.endpoints.forEach(endpoint -> {
157157
this.serverNodes.add(ClickHouseNode.of(endpoint, this.configuration));
158158
});
159-
this.metrics = metrics;
159+
this.metricsRegistry = metricsRegistry;
160160
this.serializers = new ConcurrentHashMap<>();
161161
this.deserializers = new ConcurrentHashMap<>();
162162

@@ -169,7 +169,7 @@ private Client(Set<String> endpoints, Map<String,String> configuration, boolean
169169
this.sharedOperationExecutor = sharedOperationExecutor;
170170
}
171171
boolean initSslContext = getEndpoints().stream().anyMatch(s -> s.toLowerCase().contains("https://"));
172-
this.httpClientHelper = new HttpAPIClientHelper(configuration, metrics, initSslContext);
172+
this.httpClientHelper = new HttpAPIClientHelper(configuration, metricsRegistry, initSslContext);
173173
this.columnToMethodMatchingStrategy = columnToMethodMatchingStrategy;
174174
}
175175

@@ -236,7 +236,7 @@ public static class Builder {
236236

237237
private ExecutorService sharedOperationExecutor = null;
238238
private ColumnToMethodMatchingStrategy columnToMethodMatchingStrategy;
239-
private Object metric = null;
239+
private Object metricRegistry = null;
240240
public Builder() {
241241
this.endpoints = new HashSet<>();
242242
this.configuration = new HashMap<String, String>();
@@ -961,7 +961,7 @@ public Builder useBearerTokenAuth(String bearerToken) {
961961
* @return same instance of the builder
962962
*/
963963
public Builder registerClientMetrics(Object registry, String name) {
964-
this.metric = registry;
964+
this.metricRegistry = registry;
965965
this.configuration.put(ClientConfigProperties.METRICS_GROUP_NAME.getKey(), name);
966966
return this;
967967
}
@@ -1025,7 +1025,7 @@ public Client build() {
10251025
}
10261026

10271027
return new Client(this.endpoints, this.configuration, this.useNewImplementation, this.sharedOperationExecutor,
1028-
this.columnToMethodMatchingStrategy, this.metric);
1028+
this.columnToMethodMatchingStrategy, this.metricRegistry);
10291029
}
10301030

10311031

client-v2/src/test/java/com/clickhouse/client/metrics/MetricsTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void testRegisterMetrics() throws Exception {
4949
.registerClientMetrics(meterRegistry, "pool-test")
5050
.build()) {
5151

52+
client.ping();
5253
Gauge totalMax = meterRegistry.get("httpcomponents.httpclient.pool.total.max").gauge();
5354
Gauge available = meterRegistry.get("httpcomponents.httpclient.pool.total.connections").tags("state", "available").gauge();
5455
Gauge leased = meterRegistry.get("httpcomponents.httpclient.pool.total.connections").tags("state", "leased").gauge();

0 commit comments

Comments
 (0)