masteryhx commented on code in PR #24322:
URL: https://github.com/apache/flink/pull/24322#discussion_r1519609456


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBProperty.java:
##########
@@ -31,55 +31,92 @@
  */
 @Internal
 public enum RocksDBProperty {
-    NumImmutableMemTable("num-immutable-mem-table"),
-    MemTableFlushPending("mem-table-flush-pending"),
-    CompactionPending("compaction-pending"),
-    BackgroundErrors("background-errors"),
-    CurSizeActiveMemTable("cur-size-active-mem-table"),
-    CurSizeAllMemTables("cur-size-all-mem-tables"),
-    SizeAllMemTables("size-all-mem-tables"),
-    NumEntriesActiveMemTable("num-entries-active-mem-table"),
-    NumEntriesImmMemTables("num-entries-imm-mem-tables"),
-    NumDeletesActiveMemTable("num-deletes-active-mem-table"),
-    NumDeletesImmMemTables("num-deletes-imm-mem-tables"),
-    EstimateNumKeys("estimate-num-keys"),
-    EstimateTableReadersMem("estimate-table-readers-mem"),
-    NumSnapshots("num-snapshots"),
-    NumLiveVersions("num-live-versions"),
-    EstimateLiveDataSize("estimate-live-data-size"),
-    TotalSstFilesSize("total-sst-files-size"),
-    LiveSstFilesSize("live-sst-files-size"),
-    EstimatePendingCompactionBytes("estimate-pending-compaction-bytes"),
-    NumRunningCompactions("num-running-compactions"),
-    NumRunningFlushes("num-running-flushes"),
-    ActualDelayedWriteRate("actual-delayed-write-rate"),
-    IsWriteStopped("is-write-stopped"),
-    BlockCacheCapacity("block-cache-capacity"),
-    BlockCacheUsage("block-cache-usage"),
-    BlockCachePinnedUsage("block-cache-pinned-usage");
+    NumImmutableMemTable("num-immutable-mem-table", PropertyType.NUMBER),
+    MemTableFlushPending("mem-table-flush-pending", PropertyType.NUMBER),
+    CompactionPending("compaction-pending", PropertyType.NUMBER),
+    BackgroundErrors("background-errors", PropertyType.NUMBER),
+    CurSizeActiveMemTable("cur-size-active-mem-table", PropertyType.NUMBER),
+    CurSizeAllMemTables("cur-size-all-mem-tables", PropertyType.NUMBER),
+    SizeAllMemTables("size-all-mem-tables", PropertyType.NUMBER),
+    NumEntriesActiveMemTable("num-entries-active-mem-table", 
PropertyType.NUMBER),
+    NumEntriesImmMemTables("num-entries-imm-mem-tables", PropertyType.NUMBER),
+    NumDeletesActiveMemTable("num-deletes-active-mem-table", 
PropertyType.NUMBER),
+    NumDeletesImmMemTables("num-deletes-imm-mem-tables", PropertyType.NUMBER),
+    EstimateNumKeys("estimate-num-keys", PropertyType.NUMBER),
+    EstimateTableReadersMem("estimate-table-readers-mem", PropertyType.NUMBER),
+    NumSnapshots("num-snapshots", PropertyType.NUMBER),
+    NumLiveVersions("num-live-versions", PropertyType.NUMBER),
+    EstimateLiveDataSize("estimate-live-data-size", PropertyType.NUMBER),
+    TotalSstFilesSize("total-sst-files-size", PropertyType.NUMBER),
+    LiveSstFilesSize("live-sst-files-size", PropertyType.NUMBER),
+    EstimatePendingCompactionBytes("estimate-pending-compaction-bytes", 
PropertyType.NUMBER),
+    NumRunningCompactions("num-running-compactions", PropertyType.NUMBER),
+    NumRunningFlushes("num-running-flushes", PropertyType.NUMBER),
+    ActualDelayedWriteRate("actual-delayed-write-rate", PropertyType.NUMBER),
+    IsWriteStopped("is-write-stopped", PropertyType.NUMBER),
+    BlockCacheCapacity("block-cache-capacity", PropertyType.NUMBER),
+    BlockCacheUsage("block-cache-usage", PropertyType.NUMBER),
+    BlockCachePinnedUsage("block-cache-pinned-usage", PropertyType.NUMBER),
+    NumFilesAtLevel("num-files-at-level", PropertyType.STRING);
 
     private static final String ROCKS_DB_PROPERTY_FORMAT = "rocksdb.%s";
 
     private static final String CONFIG_KEY_FORMAT = 
"state.backend.rocksdb.metrics.%s";
 
-    private final String property;
+    private final String propertyName;
 
-    RocksDBProperty(String property) {
-        this.property = property;
+    private final PropertyType type;
+
+    /** Property type. */
+    public enum PropertyType {
+        NUMBER,
+        STRING
     }
 
-    /**
-     * @return property string that can be used to query {@link
-     *     RocksDB#getLongProperty(ColumnFamilyHandle, String)}.
-     */
-    public String getRocksDBProperty() {
-        return String.format(ROCKS_DB_PROPERTY_FORMAT, property);
+    RocksDBProperty(String propertyName, PropertyType type) {
+        this.propertyName = propertyName;
+        this.type = type;
+    }
+
+    public String getPropertyName() {
+        return this.propertyName;
+    }
+
+    public static RocksDBProperty getRocksDBProperty(final String property) {
+        // NumFilesAtLevel controls multiple levels of file count monitoring, 
each a separate metric
+        if (property.startsWith(NumFilesAtLevel.getPropertyName())) {
+            return NumFilesAtLevel;
+        }
+        for (final RocksDBProperty rocksDBProperty : RocksDBProperty.values()) 
{

Review Comment:
   Agreed.
   We could just use enum class when transformed from 
RocksDBNativeMetricOptions which could make logic clear



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to