You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ch...@apache.org on 2021/03/01 06:09:11 UTC
[iotdb] branch feature/metric2021 updated: add enable logic
This is an automated email from the ASF dual-hosted git repository.
chaow pushed a commit to branch feature/metric2021
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/feature/metric2021 by this push:
new a68113f add enable logic
a68113f is described below
commit a68113fd793b208286d8fdcd2915e3c81d0d78d4
Author: chaow <xu...@gmail.com>
AuthorDate: Mon Mar 1 14:08:17 2021 +0800
add enable logic
---
.../iotdb/metrics/dropwizard/MetricName.java | 2 +-
.../org/apache/iotdb/metrics/MetricService.java | 14 +++--
.../iotdb/metrics/config/IoTDBReporterConfig.java | 69 ----------------------
.../apache/iotdb/metrics/config/MetricConfig.java | 49 +++++++++++++++
.../micrometer/MicrometerMetricReporter.java | 2 +-
5 files changed, 60 insertions(+), 76 deletions(-)
diff --git a/metrics/dropwizard-metrics/src/main/java/org/apache/iotdb/metrics/dropwizard/MetricName.java b/metrics/dropwizard-metrics/src/main/java/org/apache/iotdb/metrics/dropwizard/MetricName.java
index d214463..af722f0 100644
--- a/metrics/dropwizard-metrics/src/main/java/org/apache/iotdb/metrics/dropwizard/MetricName.java
+++ b/metrics/dropwizard-metrics/src/main/java/org/apache/iotdb/metrics/dropwizard/MetricName.java
@@ -91,7 +91,7 @@ public class MetricName {
return false;
}
MetricName that = (MetricName) obj;
- if (this.name != that.name) {
+ if (!this.name.equals(that.name)) {
return false;
}
if (that.getTags().size() != this.tags.size()) {
diff --git a/metrics/interface/src/main/java/org/apache/iotdb/metrics/MetricService.java b/metrics/interface/src/main/java/org/apache/iotdb/metrics/MetricService.java
index 5bb196a..768893a 100644
--- a/metrics/interface/src/main/java/org/apache/iotdb/metrics/MetricService.java
+++ b/metrics/interface/src/main/java/org/apache/iotdb/metrics/MetricService.java
@@ -32,6 +32,8 @@ import java.util.ServiceLoader;
public class MetricService {
private static final Logger logger = LoggerFactory.getLogger(MetricService.class);
+ private static final MetricConfig metricConfig =
+ MetricConfigDescriptor.getInstance().getMetricConfig();
static {
init();
@@ -42,9 +44,6 @@ public class MetricService {
private static MetricManager metricManager;
private static MetricReporter metricReporter;
- private static final MetricConfig metricConfig =
- MetricConfigDescriptor.getInstance().getMetricConfig();
-
public static MetricService getINSTANCE() {
return INSTANCE;
}
@@ -94,10 +93,15 @@ public class MetricService {
}
// do some init work
metricReporter.setMetricManager(metricManager);
- metricReporter.start();
+ if (isEnable()) {
+ metricReporter.start();
+ }
}
public static void stop() {
+ if (!isEnable()) {
+ return;
+ }
metricReporter.stop();
}
@@ -110,6 +114,6 @@ public class MetricService {
}
public static boolean isEnable() {
- return metricManager.isEnable();
+ return metricConfig.getEnableMetric();
}
}
diff --git a/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/IoTDBReporterConfig.java b/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/IoTDBReporterConfig.java
deleted file mode 100644
index d2ee80e..0000000
--- a/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/IoTDBReporterConfig.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.metrics.config;
-
-/** the following is iotdb related config */
-public class IoTDBReporterConfig {
- private String iotdbSg = "monitor";
- private String iotdbUser = "root";
- private String iotdbPasswd = "root";
- private String iotdbIp = "127.0.0.1";
- private String iotdbPort = "6667";
-
- public String getIotdbSg() {
- return iotdbSg;
- }
-
- public void setIotdbSg(String iotdbSg) {
- this.iotdbSg = iotdbSg;
- }
-
- public String getIotdbUser() {
- return iotdbUser;
- }
-
- public void setIotdbUser(String iotdbUser) {
- this.iotdbUser = iotdbUser;
- }
-
- public String getIotdbPasswd() {
- return iotdbPasswd;
- }
-
- public void setIotdbPasswd(String iotdbPasswd) {
- this.iotdbPasswd = iotdbPasswd;
- }
-
- public String getIotdbIp() {
- return iotdbIp;
- }
-
- public void setIotdbIp(String iotdbIp) {
- this.iotdbIp = iotdbIp;
- }
-
- public String getIotdbPort() {
- return iotdbPort;
- }
-
- public void setIotdbPort(String iotdbPort) {
- this.iotdbPort = iotdbPort;
- }
-}
diff --git a/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java b/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java
index 00b0438..b3e3017 100644
--- a/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java
+++ b/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java
@@ -113,4 +113,53 @@ public class MetricConfig {
this.prometheusExporterPort = prometheusExporterPort;
}
}
+
+ /** the following is iotdb related config */
+ public static class IoTDBReporterConfig {
+ private String iotdbSg = "_sysmetric";
+ private String iotdbUser = "root";
+ private String iotdbPasswd = "root";
+ private String iotdbIp = "127.0.0.1";
+ private String iotdbPort = "6667";
+
+ public String getIotdbSg() {
+ return iotdbSg;
+ }
+
+ public void setIotdbSg(String iotdbSg) {
+ this.iotdbSg = iotdbSg;
+ }
+
+ public String getIotdbUser() {
+ return iotdbUser;
+ }
+
+ public void setIotdbUser(String iotdbUser) {
+ this.iotdbUser = iotdbUser;
+ }
+
+ public String getIotdbPasswd() {
+ return iotdbPasswd;
+ }
+
+ public void setIotdbPasswd(String iotdbPasswd) {
+ this.iotdbPasswd = iotdbPasswd;
+ }
+
+ public String getIotdbIp() {
+ return iotdbIp;
+ }
+
+ public void setIotdbIp(String iotdbIp) {
+ this.iotdbIp = iotdbIp;
+ }
+
+ public String getIotdbPort() {
+ return iotdbPort;
+ }
+
+ public void setIotdbPort(String iotdbPort) {
+ this.iotdbPort = iotdbPort;
+ }
+ }
}
diff --git a/metrics/micrometer-metrics/src/main/java/org/apache/iotdb/metrics/micrometer/MicrometerMetricReporter.java b/metrics/micrometer-metrics/src/main/java/org/apache/iotdb/metrics/micrometer/MicrometerMetricReporter.java
index f261dc2..02cf63e 100644
--- a/metrics/micrometer-metrics/src/main/java/org/apache/iotdb/metrics/micrometer/MicrometerMetricReporter.java
+++ b/metrics/micrometer-metrics/src/main/java/org/apache/iotdb/metrics/micrometer/MicrometerMetricReporter.java
@@ -44,6 +44,7 @@ public class MicrometerMetricReporter implements MetricReporter {
@Override
public boolean start() {
+
List<String> reporters = metricConfig.getMetricReporterList();
for (String reporter : reporters) {
switch (ReporterType.get(reporter)) {
@@ -92,7 +93,6 @@ public class MicrometerMetricReporter implements MetricReporter {
private void startJmxReporter(JmxMeterRegistry jmxMeterRegistry) {
logger.info("start jmx reporter from micrometer");
- // jmxMeterRegistry.start();
}
@Override