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

[iotdb] 01/01: use ConcurrentHashMap instead of HashMap

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

marklau99 pushed a commit to branch fix-concurrent-modification
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 7b9dcc87ff890400523fa2a26d0c58ef2410d206
Author: Liu Xuxin <li...@outlook.com>
AuthorDate: Thu Jun 1 21:29:06 2023 +0800

    use ConcurrentHashMap instead of HashMap
---
 .../java/org/apache/iotdb/db/service/metrics/FileMetrics.java    | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/service/metrics/FileMetrics.java b/server/src/main/java/org/apache/iotdb/db/service/metrics/FileMetrics.java
index 110b3ed559d..1b82f2a512d 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/metrics/FileMetrics.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/metrics/FileMetrics.java
@@ -44,7 +44,6 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -89,10 +88,10 @@ public class FileMetrics implements IMetricSet {
   private final AtomicInteger innerUnseqCompactionTempFileNum = new AtomicInteger(0);
   private final AtomicInteger crossCompactionTempFileNum = new AtomicInteger(0);
   private AtomicBoolean hasRemainData = new AtomicBoolean(false);
-  private final Map<Integer, Gauge> seqLevelCountGaugeMap = new HashMap<>();
-  private final Map<Integer, Gauge> seqLevelSizeGaugeMap = new HashMap<>();
-  private final Map<Integer, Gauge> unseqLevelCountGaugeMap = new HashMap<>();
-  private final Map<Integer, Gauge> unseqLevelSizeGaugeMap = new HashMap<>();
+  private final Map<Integer, Gauge> seqLevelCountGaugeMap = new ConcurrentHashMap<>();
+  private final Map<Integer, Gauge> seqLevelSizeGaugeMap = new ConcurrentHashMap<>();
+  private final Map<Integer, Gauge> unseqLevelCountGaugeMap = new ConcurrentHashMap<>();
+  private final Map<Integer, Gauge> unseqLevelSizeGaugeMap = new ConcurrentHashMap<>();
 
   @SuppressWarnings("squid:S1075")
   private String fileHandlerCntPathInLinux = "/proc/%s/fd";