ibessonov commented on code in PR #6692:
URL: https://github.com/apache/ignite-3/pull/6692#discussion_r2405845067


##########
modules/storage-page-memory/src/test/java/org/apache/ignite/internal/storage/pagememory/engine/PersistentPageMemoryStorageEngineTest.java:
##########
@@ -98,4 +108,34 @@ void dataRegionSizeUsedWhenSet(
     protected void persistTableDestructionIfNeeded() {
         // No-op as table destruction is durable for this engine.
     }
+
+    @Test
+    @Override
+    protected void tableMetrics() {
+        var engine = (PersistentPageMemoryStorageEngine) storageEngine;
+
+        var tableDescriptor = new StorageTableDescriptor(10, 1, 
CatalogService.DEFAULT_STORAGE_PROFILE);
+        MvTableStorage table = engine.createMvTable(tableDescriptor, indexId 
-> null);
+
+        List<Metric> metricsList = new ArrayList<>();
+        engine.addTableMetrics(tableDescriptor, metricsList::add);
+
+        assertThat(metricsList.size(), is(1));
+
+        Metric metric = metricsList.get(0);
+        assertThat(metric.name(), is("TotalAllocatedSize"));
+        assertThat(metric, is(instanceOf(LongMetric.class)));
+
+        LongMetric totalAllocatedSize = (LongMetric) metric;
+        assertEquals(0, totalAllocatedSize.value());
+
+        var otherTableDescriptor = new StorageTableDescriptor(20, 1, 
CatalogService.DEFAULT_STORAGE_PROFILE);
+        MvTableStorage otherTable = engine.createMvTable(otherTableDescriptor, 
indexId -> null);
+
+        otherTable.createMvPartition(0);
+        assertEquals(0, totalAllocatedSize.value());
+
+        table.createMvPartition(0);
+        assertThat(totalAllocatedSize.value(), is(greaterThan(0L)));

Review Comment:
   For what reason? I see no necessity in that, it would only bloat the code



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/PersistentPageMemoryDataRegion.java:
##########
@@ -459,10 +462,30 @@ private void initMetrics() {
         ));
     }
 
+    /**
+     * Registers region-specific metrics for the given table.
+     *
+     * @param tableDescriptor Table descriptor.
+     * @param metricConsumer Abstract metric consumer for registering metrics.
+     */
+    void addTableMetrics(StorageTableDescriptor tableDescriptor, 
Consumer<Metric> metricConsumer) {
+        PersistentPageMemoryTableStorage tableStorage = 
tableStorages.get(tableDescriptor.getId());
+
+        assert tableStorage != null : "Adding metrics for a non-existent 
table: " + tableDescriptor;
+
+        metricConsumer.accept(new LongGauge(
+                "TotalAllocatedSize",
+                "desc",

Review Comment:
   Yes



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to