This is an automated email from the ASF dual-hosted git repository. haonan pushed a commit to branch metric_ssl in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 9ebd69a568ef39115974909773c0ce7918df9457 Author: HTHou <[email protected]> AuthorDate: Fri Sep 5 18:11:39 2025 +0800 function works --- .../apache/iotdb/metrics/config/MetricConfig.java | 4 ++++ .../reporter/iotdb/IoTDBSessionReporter.java | 9 ++++---- .../reporter/prometheus/PrometheusReporter.java | 27 ++++++++++------------ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java index 1b9cafbe0cb..b71bb6ad882 100644 --- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java +++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java @@ -173,6 +173,10 @@ public class MetricConfig { return enableSSL; } + public void setEnableSSL(boolean enableSSL) { + this.enableSSL = enableSSL; + } + public String getKeyStorePath() { return keyStorePath; } diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/iotdb/IoTDBSessionReporter.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/iotdb/IoTDBSessionReporter.java index 61e223d58f2..62392b8b124 100644 --- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/iotdb/IoTDBSessionReporter.java +++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/iotdb/IoTDBSessionReporter.java @@ -70,10 +70,11 @@ public class IoTDBSessionReporter extends IoTDBReporter { .password(ioTDBReporterConfig.getPassword()) .maxSize(ioTDBReporterConfig.getMaxConnectionNumber()); if (metricConfig.isEnableSSL()) { - sessionPoolBuilder - .useSSL(true) - .trustStore(metricConfig.getTrustStorePath()) - .trustStorePwd(metricConfig.getTrustStorePassword()); + sessionPoolBuilder = + sessionPoolBuilder + .useSSL(true) + .trustStore(metricConfig.getTrustStorePath()) + .trustStorePwd(metricConfig.getTrustStorePassword()); } this.sessionPool = sessionPoolBuilder.build(); try (SessionDataSetWrapper result = diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusReporter.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusReporter.java index 9c1ec0890fe..b8997ea0dcd 100644 --- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusReporter.java +++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusReporter.java @@ -106,21 +106,18 @@ public class PrometheusReporter implements Reporter { .sendString(Mono.just(scrape())); })); if (METRIC_CONFIG.isEnableSSL()) { - serverTransport.secure( - spec -> { - SslContext sslContext; - try { - sslContext = - createSslContext( - METRIC_CONFIG.getKeyStorePath(), - METRIC_CONFIG.getKeyStorePassword(), - METRIC_CONFIG.getTrustStorePath(), - METRIC_CONFIG.getTrustStorePassword()); - } catch (Exception e) { - throw new RuntimeException(e); - } - spec.sslContext(sslContext); - }); + SslContext sslContext; + try { + sslContext = + createSslContext( + METRIC_CONFIG.getKeyStorePath(), + METRIC_CONFIG.getKeyStorePassword(), + METRIC_CONFIG.getTrustStorePath(), + METRIC_CONFIG.getTrustStorePassword()); + } catch (Exception e) { + throw new RuntimeException(e); + } + serverTransport = serverTransport.secure(spec -> spec.sslContext(sslContext)); } httpServer = serverTransport.bindNow(); } catch (Throwable e) {
