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/07/14 02:42:35 UTC

[iotdb] branch master updated: [IOTDB-6066] Add ConfigNode timeslot metric (#10546)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 28419967a71 [IOTDB-6066] Add ConfigNode timeslot metric (#10546)
28419967a71 is described below

commit 28419967a71bb92e4a2030a46e66b4fb799d4142
Author: Xiangpeng Hu <65...@users.noreply.github.com>
AuthorDate: Fri Jul 14 10:42:29 2023 +0800

    [IOTDB-6066] Add ConfigNode timeslot metric (#10546)
    
    * add timeseries_slot metric
    
    * compute directly
    
    * fix compute
---
 .../confignode/manager/partition/PartitionManager.java   | 12 ++++++++++++
 .../confignode/manager/partition/PartitionMetrics.java   | 16 ++++++++++++++++
 .../persistence/partition/DatabasePartitionTable.java    |  4 ++++
 .../confignode/persistence/partition/PartitionInfo.java  | 12 ++++++++++++
 .../iotdb/commons/partition/DataPartitionTable.java      | 12 ++++++++++--
 .../iotdb/commons/service/metric/enums/Metric.java       |  1 +
 6 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java
index 808ca325886..fae18091d36 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java
@@ -752,6 +752,18 @@ public class PartitionManager {
     return partitionInfo.getAssignedSeriesPartitionSlotsCount(database);
   }
 
+  /**
+   * Only leader use this interface.
+   *
+   * <p>Get the assigned TimePartitionSlots count in the specified Database
+   *
+   * @param database The specified Database
+   * @return The assigned TimePartitionSlots count
+   */
+  public long getAssignedTimePartitionSlotsCount(String database) {
+    return partitionInfo.getAssignedTimePartitionSlotsCount(database);
+  }
+
   /**
    * Only leader use this interface.
    *
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionMetrics.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionMetrics.java
index bda61a229b7..8a5cd1f5a86 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionMetrics.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionMetrics.java
@@ -232,6 +232,15 @@ public class PartitionMetrics implements IMetricSet {
         Tag.NAME.toString(),
         database);
 
+    // Count the number of TimeSlots in the specified Database
+    metricService.createAutoGauge(
+        Metric.TIME_SLOT_NUM_IN_DATABASE.toString(),
+        MetricLevel.CORE,
+        partitionManager,
+        manager -> manager.getAssignedTimePartitionSlotsCount(database),
+        Tag.NAME.toString(),
+        database);
+
     // Count the number of RegionGroups in the specified Database
     metricService.createAutoGauge(
         Metric.REGION_GROUP_NUM_IN_DATABASE.toString(),
@@ -290,6 +299,13 @@ public class PartitionMetrics implements IMetricSet {
         Tag.NAME.toString(),
         database);
 
+    // Remove the number of TimeSlots in the specified Database
+    metricService.remove(
+        MetricType.AUTO_GAUGE,
+        Metric.TIME_SLOT_NUM_IN_DATABASE.toString(),
+        Tag.NAME.toString(),
+        database);
+
     // Remove number of RegionGroups in the specified Database
     metricService.remove(
         MetricType.AUTO_GAUGE,
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/DatabasePartitionTable.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/DatabasePartitionTable.java
index bec09cf81b2..b2ca2faf6b7 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/DatabasePartitionTable.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/DatabasePartitionTable.java
@@ -453,6 +453,10 @@ public class DatabasePartitionTable {
     return dataPartitionTable.getTimeSlotList(seriesSlotId, regionId, startTime, endTime);
   }
 
+  public long getTimeSlotCount() {
+    return dataPartitionTable.getTimeSlotCount();
+  }
+
   public List<TSeriesPartitionSlot> getSeriesSlotList(TConsensusGroupType type) {
     if (type == TConsensusGroupType.DataRegion) {
       return dataPartitionTable.getSeriesSlotList();
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
index 8624ba333c3..d85c63e4e10 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
@@ -734,6 +734,18 @@ public class PartitionInfo implements SnapshotProcessor {
     return databasePartitionTables.get(database).getAssignedSeriesPartitionSlotsCount();
   }
 
+  /**
+   * Only leader use this interface.
+   *
+   * <p>Get the assigned TimePartitionSlots count in the specified Database
+   *
+   * @param database The specified Database
+   * @return The assigned TimePartitionSlots count
+   */
+  public long getAssignedTimePartitionSlotsCount(String database) {
+    return databasePartitionTables.get(database).getTimeSlotCount();
+  }
+
   /**
    * Get the DataNodes who contain the specific StorageGroup's Schema or Data.
    *
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartitionTable.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartitionTable.java
index 979b594a690..1a5611536ae 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartitionTable.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartitionTable.java
@@ -200,8 +200,7 @@ public class DataPartitionTable {
    * @param seriesSlotId SeriesPartitionSlot
    * @param regionId TConsensusGroupId
    * @param startTime startTime
-   * @return the timePartition if seriesSlotId==-1&&regionId == -1, then return all timePartition;
-   *     if timeSlotId == -1, then return all the seriesSlot's dataRegionIds.
+   * @return the timePartition if seriesSlotId==-1 && regionId == -1, then return all timePartition.
    */
   public List<TTimePartitionSlot> getTimeSlotList(
       TSeriesPartitionSlot seriesSlotId, TConsensusGroupId regionId, long startTime, long endTime) {
@@ -222,6 +221,15 @@ public class DataPartitionTable {
     }
   }
 
+  /** Get timePartitionSlot count. */
+  public long getTimeSlotCount() {
+    AtomicLong sum = new AtomicLong();
+    dataPartitionMap.forEach(
+        (seriesPartitionSlot, seriesPartitionTable) ->
+            sum.addAndGet(seriesPartitionTable.getSeriesPartitionMap().size()));
+    return sum.get();
+  }
+
   public List<TSeriesPartitionSlot> getSeriesSlotList() {
     return dataPartitionMap.keySet().stream()
         .sorted(Comparator.comparing(TSeriesPartitionSlot::getSlotId))
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java
index ae8fef76ec5..722c276e9e9 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java
@@ -34,6 +34,7 @@ public enum Metric {
   REGION_NUM_IN_DATA_NODE("region_num_in_data_node"),
   REGION_GROUP_LEADER_NUM_IN_DATA_NODE("region_group_leader_num_in_data_node"),
   SERIES_SLOT_NUM_IN_DATABASE("series_slot_num_in_database"),
+  TIME_SLOT_NUM_IN_DATABASE("time_slot_num_in_database"),
   REGION_GROUP_NUM_IN_DATABASE("region_group_num_in_database"),
   // protocol related
   ENTRY("entry"),