You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by sp...@apache.org on 2023/06/28 13:48:50 UTC

[iotdb] 05/06: Fix Interface code smell

This is an automated email from the ASF dual-hosted git repository.

spricoder pushed a commit to branch optimize/metric_code_smell
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 8cf77ea88f84ca6e1dd57e87dded5d187194d3aa
Author: spricoder <sp...@qq.com>
AuthorDate: Wed Jun 28 21:48:05 2023 +0800

    Fix Interface code smell
---
 .../iotdb/metrics/AbstractMetricManager.java       | 21 +++++-------
 .../iotdb/metrics/AbstractMetricService.java       |  6 ++--
 .../apache/iotdb/metrics/config/MetricConfig.java  | 22 ++++++++++---
 .../metrics/config/MetricConfigDescriptor.java     |  6 ++--
 .../iotdb/metrics/metricsets/UpTimeMetrics.java    |  2 +-
 .../iotdb/metrics/metricsets/jvm/JvmGcMetrics.java | 38 +++++++++-------------
 .../metrics/metricsets/jvm/JvmMemoryMetrics.java   |  6 ++--
 .../metrics/metricsets/jvm/JvmThreadMetrics.java   |  6 ++--
 .../iotdb/metrics/metricsets/jvm/JvmUtils.java     |  5 +++
 .../metrics/metricsets/logback/LogbackMetrics.java | 12 ++++---
 .../reporter/iotdb/IoTDBSessionReporter.java       |  2 +-
 .../iotdb/metrics/config/MetricConfigTest.java     |  4 +--
 12 files changed, 68 insertions(+), 62 deletions(-)

diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricManager.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricManager.java
index e077598ba30..66c4fae54d1 100644
--- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricManager.java
+++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricManager.java
@@ -46,12 +46,13 @@ import java.util.function.ToDoubleFunction;
 public abstract class AbstractMetricManager {
   protected static final MetricConfig METRIC_CONFIG =
       MetricConfigDescriptor.getInstance().getMetricConfig();
+  private static final String ALREADY_EXISTS = " is already used for a different type of name";
   /** The map from metric name to metric metaInfo. */
   protected Map<String, MetricInfo.MetaInfo> nameToMetaInfo;
   /** The map from metricInfo to metric. */
   protected Map<MetricInfo, IMetric> metrics;
 
-  public AbstractMetricManager() {
+  protected AbstractMetricManager() {
     nameToMetaInfo = new ConcurrentHashMap<>();
     metrics = new ConcurrentHashMap<>();
   }
@@ -80,8 +81,7 @@ public abstract class AbstractMetricManager {
     if (metric instanceof Counter) {
       return (Counter) metric;
     }
-    throw new IllegalArgumentException(
-        metricInfo + " is already used for a different type of name");
+    throw new IllegalArgumentException(metricInfo + ALREADY_EXISTS);
   }
 
   protected abstract Counter createCounter(MetricInfo metricInfo);
@@ -138,8 +138,7 @@ public abstract class AbstractMetricManager {
     } else if (metric instanceof AutoGauge) {
       return (AutoGauge) metric;
     }
-    throw new IllegalArgumentException(
-        metricInfo + " is already used for a different type of name");
+    throw new IllegalArgumentException(metricInfo + ALREADY_EXISTS);
   }
 
   /**
@@ -166,8 +165,7 @@ public abstract class AbstractMetricManager {
     if (metric instanceof Gauge) {
       return (Gauge) metric;
     }
-    throw new IllegalArgumentException(
-        metricInfo + " is already used for a different type of name");
+    throw new IllegalArgumentException(metricInfo + ALREADY_EXISTS);
   }
 
   /**
@@ -201,8 +199,7 @@ public abstract class AbstractMetricManager {
     if (metric instanceof Rate) {
       return (Rate) metric;
     }
-    throw new IllegalArgumentException(
-        metricInfo + " is already used for a different type of name");
+    throw new IllegalArgumentException(metricInfo + ALREADY_EXISTS);
   }
 
   /**
@@ -236,8 +233,7 @@ public abstract class AbstractMetricManager {
     if (metric instanceof Histogram) {
       return (Histogram) metric;
     }
-    throw new IllegalArgumentException(
-        metricInfo + " is already used for a different type of name");
+    throw new IllegalArgumentException(metricInfo + ALREADY_EXISTS);
   }
 
   /**
@@ -271,8 +267,7 @@ public abstract class AbstractMetricManager {
     if (metric instanceof Timer) {
       return (Timer) metric;
     }
-    throw new IllegalArgumentException(
-        metricInfo + " is already used for a different type of name");
+    throw new IllegalArgumentException(metricInfo + ALREADY_EXISTS);
   }
 
   /**
diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricService.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricService.java
index 31e1e352ed1..5ac5a3737f2 100644
--- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricService.java
+++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/AbstractMetricService.java
@@ -70,7 +70,7 @@ public abstract class AbstractMetricService {
   /** The list of metric sets. */
   protected Set<IMetricSet> metricSets = new HashSet<>();
 
-  public AbstractMetricService() {
+  protected AbstractMetricService() {
     // empty constructor
   }
 
@@ -169,7 +169,7 @@ public abstract class AbstractMetricService {
           reporter = new IoTDBSessionReporter(metricManager);
           break;
         default:
-          continue;
+          break;
       }
       if (reporter == null) {
         LOGGER.warn("Failed to load reporter which type is {}", reporterType);
@@ -324,7 +324,7 @@ public abstract class AbstractMetricService {
         metricManager.count(delta, metric, metricLevel, tags), metric, tags);
   }
 
-  /** Gauge value with internal report */
+  /** Gauge value with internal report. */
   public void gaugeWithInternalReportAsync(
       long value, String metric, MetricLevel metricLevel, String... tags) {
     internalReporter.writeMetricToIoTDB(
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 8be699eb106..125c09b79b7 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
@@ -53,7 +53,7 @@ public class MetricConfig {
   private Integer prometheusReporterPort = 9091;
 
   /** The iotdb config for iotdb reporter to push metric data. */
-  private final IoTDBReporterConfig iotdbReporterConfig = new IoTDBReporterConfig();
+  private final IotdbReporterConfig iotdbReporterConfig = new IotdbReporterConfig();
 
   /** The type of internal reporter. */
   private InternalReporterType internalReporterType = InternalReporterType.MEMORY;
@@ -134,7 +134,7 @@ public class MetricConfig {
     this.prometheusReporterPort = prometheusReporterPort;
   }
 
-  public IoTDBReporterConfig getIotdbReporterConfig() {
+  public IotdbReporterConfig getIotdbReporterConfig() {
     return iotdbReporterConfig;
   }
 
@@ -205,7 +205,19 @@ public class MetricConfig {
         && internalReporterType.equals(anotherMetricConfig.getInternalReportType());
   }
 
-  public static class IoTDBReporterConfig {
+  @Override
+  public int hashCode() {
+    return Objects.hash(
+        metricFrameType,
+        metricReporterList,
+        metricLevel,
+        asyncCollectPeriodInSecond,
+        prometheusReporterPort,
+        iotdbReporterConfig,
+        internalReporterType);
+  }
+
+  public static class IotdbReporterConfig {
     /** The host of iotdb that store metric value. */
     private String host = "127.0.0.1";
     /** The port of iotdb that store metric value. */
@@ -277,7 +289,7 @@ public class MetricConfig {
       this.pushPeriodInSecond = pushPeriodInSecond;
     }
 
-    public void copy(IoTDBReporterConfig iotdbReporterConfig) {
+    public void copy(IotdbReporterConfig iotdbReporterConfig) {
       host = iotdbReporterConfig.getHost();
       port = iotdbReporterConfig.getPort();
       username = iotdbReporterConfig.getUsername();
@@ -295,7 +307,7 @@ public class MetricConfig {
       if (o == null || getClass() != o.getClass()) {
         return false;
       }
-      IoTDBReporterConfig that = (IoTDBReporterConfig) o;
+      IotdbReporterConfig that = (IotdbReporterConfig) o;
       return Objects.equals(host, that.host)
           && Objects.equals(port, that.port)
           && Objects.equals(username, that.username)
diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfigDescriptor.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfigDescriptor.java
index 9125ca3683b..d893677eec3 100644
--- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfigDescriptor.java
+++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfigDescriptor.java
@@ -30,10 +30,10 @@ import java.util.stream.Collectors;
 /** The utils class to load properties. */
 public class MetricConfigDescriptor {
   /** The metric config of metric service. */
-  private final MetricConfig metricConfig;
+  private static final MetricConfig metricConfig = new MetricConfig();
 
   private MetricConfigDescriptor() {
-    metricConfig = new MetricConfig();
+    // empty constructor
   }
 
   /** Load properties into metric config. */
@@ -110,7 +110,7 @@ public class MetricConfigDescriptor {
                 String.valueOf(loadConfig.getPrometheusReporterPort()),
                 properties)));
 
-    MetricConfig.IoTDBReporterConfig reporterConfig = loadConfig.getIotdbReporterConfig();
+    MetricConfig.IotdbReporterConfig reporterConfig = loadConfig.getIotdbReporterConfig();
     reporterConfig.setHost(
         getProperty("metric_iotdb_reporter_host", reporterConfig.getHost(), properties));
 
diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/UpTimeMetrics.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/UpTimeMetrics.java
index 2955723250e..0f442100413 100644
--- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/UpTimeMetrics.java
+++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/UpTimeMetrics.java
@@ -34,7 +34,7 @@ public class UpTimeMetrics implements IMetricSet {
         "up_time",
         MetricLevel.CORE,
         metricConfig,
-        (config) -> System.nanoTime() - config.getUpTimeInNs());
+        config -> System.nanoTime() - config.getUpTimeInNs());
   }
 
   @Override
diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmGcMetrics.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmGcMetrics.java
index 857fc2ecfaa..b7266beb2e1 100644
--- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmGcMetrics.java
+++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmGcMetrics.java
@@ -44,7 +44,6 @@ import java.lang.management.MemoryUsage;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
@@ -255,7 +254,8 @@ public class JvmGcMetrics implements IMetricSet, AutoCloseable {
   private boolean preCheck() {
     if (ManagementFactory.getMemoryPoolMXBeans().isEmpty()) {
       logger.warn(
-          "GC notifications will not be available because MemoryPoolMXBeans are not provided by the JVM");
+          "GC notifications will not be available because MemoryPoolMXBeans "
+              + "are not provided by the JVM");
       return false;
     }
 
@@ -264,7 +264,7 @@ public class JvmGcMetrics implements IMetricSet, AutoCloseable {
           "com.sun.management.GarbageCollectionNotificationInfo",
           false,
           MemoryPoolMXBean.class.getClassLoader());
-    } catch (Throwable e) {
+    } catch (Exception e) {
       // We are operating in a JVM without access to this level of detail
       logger.warn(
           "GC notifications will not be available because "
@@ -299,32 +299,24 @@ public class JvmGcMetrics implements IMetricSet, AutoCloseable {
     YOUNG,
     UNKNOWN;
 
-    private static Map<String, GcGenerationAge> knownCollectors =
-        new HashMap<String, GcGenerationAge>() {
-          {
-            put("ConcurrentMarkSweep", OLD);
-            put("Copy", YOUNG);
-            put("G1 Old Generation", OLD);
-            put("G1 Young Generation", YOUNG);
-            put("MarkSweepCompact", OLD);
-            put("PS MarkSweep", OLD);
-            put("PS Scavenge", YOUNG);
-            put("ParNew", YOUNG);
-          }
-        };
+    private static Map<String, GcGenerationAge> knownCollectors = new HashMap<>();
+
+    static {
+      knownCollectors.put("ConcurrentMarkSweep", OLD);
+      knownCollectors.put("Copy", YOUNG);
+      knownCollectors.put("G1 Old Generation", OLD);
+      knownCollectors.put("G1 Young Generation", YOUNG);
+      knownCollectors.put("MarkSweepCompact", OLD);
+      knownCollectors.put("PS MarkSweep", OLD);
+      knownCollectors.put("PS Scavenge", YOUNG);
+      knownCollectors.put("ParNew", YOUNG);
+    }
 
     static GcGenerationAge fromName(String name) {
       return knownCollectors.getOrDefault(name, UNKNOWN);
     }
   }
 
-  private static Optional<MemoryPoolMXBean> getLongLivedHeapPool() {
-    return ManagementFactory.getPlatformMXBeans(MemoryPoolMXBean.class).stream()
-        .filter(JvmGcMetrics::isHeap)
-        .filter(mem -> isOldGenPool(mem.getName()) || isNonGenerationalHeapPool(mem.getName()))
-        .findAny();
-  }
-
   private static boolean isConcurrentPhase(String cause, String name) {
     return "No GC".equals(cause) || "Shenandoah Cycles".equals(name);
   }
diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmMemoryMetrics.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmMemoryMetrics.java
index efef8aae98f..bf23121dfaa 100644
--- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmMemoryMetrics.java
+++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmMemoryMetrics.java
@@ -69,7 +69,7 @@ public class JvmMemoryMetrics implements IMetricSet {
           "jvm_memory_used_bytes",
           MetricLevel.CORE,
           memoryPoolBean,
-          (mem) -> JvmUtils.getUsageValue(mem, MemoryUsage::getUsed),
+          mem -> JvmUtils.getUsageValue(mem, MemoryUsage::getUsed),
           "id",
           memoryPoolBean.getName(),
           "area",
@@ -79,7 +79,7 @@ public class JvmMemoryMetrics implements IMetricSet {
           "jvm_memory_committed_bytes",
           MetricLevel.CORE,
           memoryPoolBean,
-          (mem) -> JvmUtils.getUsageValue(mem, MemoryUsage::getCommitted),
+          mem -> JvmUtils.getUsageValue(mem, MemoryUsage::getCommitted),
           "id",
           memoryPoolBean.getName(),
           "area",
@@ -89,7 +89,7 @@ public class JvmMemoryMetrics implements IMetricSet {
           "jvm_memory_max_bytes",
           MetricLevel.CORE,
           memoryPoolBean,
-          (mem) -> JvmUtils.getUsageValue(mem, MemoryUsage::getMax),
+          mem -> JvmUtils.getUsageValue(mem, MemoryUsage::getMax),
           "id",
           memoryPoolBean.getName(),
           "area",
diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmThreadMetrics.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmThreadMetrics.java
index 6a6643fbf7e..1dbc5600cc9 100644
--- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmThreadMetrics.java
+++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmThreadMetrics.java
@@ -62,11 +62,11 @@ public class JvmThreadMetrics implements IMetricSet {
             "jvm_threads_states_threads",
             MetricLevel.CORE,
             threadBean,
-            (bean) -> getThreadStateCount(bean, state),
+            bean -> getThreadStateCount(bean, state),
             "state",
             getStateTagValue(state));
       }
-    } catch (Error error) {
+    } catch (Exception exception) {
       // An error will be thrown for unsupported operations
       // e.g. SubstrateVM does not support getAllThreadIds
     }
@@ -86,7 +86,7 @@ public class JvmThreadMetrics implements IMetricSet {
         metricService.remove(
             MetricType.AUTO_GAUGE, "jvm_threads_states_threads", "state", getStateTagValue(state));
       }
-    } catch (Error error) {
+    } catch (Exception exception) {
       // An error will be thrown for unsupported operations
       // e.g. SubstrateVM does not support getAllThreadIds
     }
diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmUtils.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmUtils.java
index 4455e2d61e7..8b91e01ce53 100644
--- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmUtils.java
+++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmUtils.java
@@ -24,6 +24,11 @@ import java.lang.management.MemoryUsage;
 import java.util.function.ToLongFunction;
 
 public class JvmUtils {
+
+  private JvmUtils() {
+    // util class
+  }
+
   static double getUsageValue(
       MemoryPoolMXBean memoryPoolMxBean, ToLongFunction<MemoryUsage> getter) {
     MemoryUsage usage = getUsage(memoryPoolMxBean);
diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/logback/LogbackMetrics.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/logback/LogbackMetrics.java
index 852ad6c28b1..e7766e944f2 100644
--- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/logback/LogbackMetrics.java
+++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/logback/LogbackMetrics.java
@@ -35,6 +35,8 @@ import java.util.Map;
 /** This file is modified from io.micrometer.core.instrument.binder.logging.LogbackMetrics */
 public class LogbackMetrics implements IMetricSet {
   private static final org.slf4j.Logger logger = LoggerFactory.getLogger(LogbackMetrics.class);
+  private static final String LEVEL = "level";
+  private static final String METRIC_NAME = "logback_events";
   static ThreadLocal<Boolean> ignoreMetrics = new ThreadLocal<>();
   private final LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
   private final Map<AbstractMetricService, MetricsTurboFilter> metricsTurboFilters =
@@ -91,11 +93,11 @@ public class LogbackMetrics implements IMetricSet {
         for (MetricsTurboFilter addMetricsTurboFilter : metricsTurboFilters.values()) {
           loggerContext.getTurboFilterList().remove(addMetricsTurboFilter);
         }
-        metricService.remove(MetricType.COUNTER, "logback_events", "level", "error");
-        metricService.remove(MetricType.COUNTER, "logback_events", "level", "warn");
-        metricService.remove(MetricType.COUNTER, "logback_events", "level", "info");
-        metricService.remove(MetricType.COUNTER, "logback_events", "level", "debug");
-        metricService.remove(MetricType.COUNTER, "logback_events", "level", "trace");
+        metricService.remove(MetricType.COUNTER, METRIC_NAME, LEVEL, "error");
+        metricService.remove(MetricType.COUNTER, METRIC_NAME, LEVEL, "warn");
+        metricService.remove(MetricType.COUNTER, METRIC_NAME, LEVEL, "info");
+        metricService.remove(MetricType.COUNTER, METRIC_NAME, LEVEL, "debug");
+        metricService.remove(MetricType.COUNTER, METRIC_NAME, LEVEL, "trace");
       }
     } catch (Exception e) {
       logger.warn("Failed to remove logBackMetrics, because ", e);
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 af5a0529f78..12fa003c0db 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
@@ -48,7 +48,7 @@ public class IoTDBSessionReporter extends IoTDBReporter {
   private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBSessionReporter.class);
   private static final MetricConfig metricConfig =
       MetricConfigDescriptor.getInstance().getMetricConfig();
-  private static final MetricConfig.IoTDBReporterConfig ioTDBReporterConfig =
+  private static final MetricConfig.IotdbReporterConfig ioTDBReporterConfig =
       MetricConfigDescriptor.getInstance().getMetricConfig().getIotdbReporterConfig();
   private Future<?> currentServiceFuture;
   private final ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
diff --git a/iotdb-core/metrics/interface/src/test/java/org/apache/iotdb/metrics/config/MetricConfigTest.java b/iotdb-core/metrics/interface/src/test/java/org/apache/iotdb/metrics/config/MetricConfigTest.java
index dacc733db91..fa408eb6ff9 100644
--- a/iotdb-core/metrics/interface/src/test/java/org/apache/iotdb/metrics/config/MetricConfigTest.java
+++ b/iotdb-core/metrics/interface/src/test/java/org/apache/iotdb/metrics/config/MetricConfigTest.java
@@ -58,7 +58,7 @@ public class MetricConfigTest {
     assertEquals(10, (int) metricConfig.getAsyncCollectPeriodInSecond());
     assertEquals(9090, (int) metricConfig.getPrometheusReporterPort());
 
-    MetricConfig.IoTDBReporterConfig reporterConfig = metricConfig.getIotdbReporterConfig();
+    MetricConfig.IotdbReporterConfig reporterConfig = metricConfig.getIotdbReporterConfig();
     assertEquals("0.0.0.0", reporterConfig.getHost());
     assertEquals(6669, (int) reporterConfig.getPort());
     assertEquals("user", reporterConfig.getUsername());
@@ -97,7 +97,7 @@ public class MetricConfigTest {
     assertEquals(10, (int) metricConfig.getAsyncCollectPeriodInSecond());
     assertEquals(9090, (int) metricConfig.getPrometheusReporterPort());
 
-    MetricConfig.IoTDBReporterConfig reporterConfig = metricConfig.getIotdbReporterConfig();
+    MetricConfig.IotdbReporterConfig reporterConfig = metricConfig.getIotdbReporterConfig();
     assertEquals("0.0.0.0", reporterConfig.getHost());
     assertEquals(6669, (int) reporterConfig.getPort());
     assertEquals("user", reporterConfig.getUsername());