This is an automated email from the ASF dual-hosted git repository.
ppa pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 05ccdbd63f6 IGNITE-27813 Sql. Don't enable partition modification
counter metrics by default (#7686)
05ccdbd63f6 is described below
commit 05ccdbd63f60d5c7a8b0e6eb447c2e24b9e14eed
Author: Ilya Korol <[email protected]>
AuthorDate: Wed Mar 4 15:07:57 2026 +0300
IGNITE-27813 Sql. Don't enable partition modification counter metrics by
default (#7686)
---
.../internal/metrics/AbstractMetricManager.java | 15 +-
.../table/BasePartitionTableStatsMetricTest.java | 127 +++++++++++++
...PartitionTableStatsMetricConfigurationTest.java | 6 +-
.../table/ItPartitionTableStatsMetricTest.java | 196 ++++++++-------------
.../internal/table/distributed/TableManager.java | 3 +-
5 files changed, 219 insertions(+), 128 deletions(-)
diff --git
a/modules/metrics/src/main/java/org/apache/ignite/internal/metrics/AbstractMetricManager.java
b/modules/metrics/src/main/java/org/apache/ignite/internal/metrics/AbstractMetricManager.java
index 072d35836ff..bdcbf5a3dec 100644
---
a/modules/metrics/src/main/java/org/apache/ignite/internal/metrics/AbstractMetricManager.java
+++
b/modules/metrics/src/main/java/org/apache/ignite/internal/metrics/AbstractMetricManager.java
@@ -34,6 +34,7 @@ import
org.apache.ignite.internal.lang.IgniteInternalException;
import org.apache.ignite.internal.manager.ComponentContext;
import org.apache.ignite.internal.metrics.exporters.MetricExporter;
import org.apache.ignite.internal.util.IgniteSpinBusyLock;
+import org.jetbrains.annotations.Nullable;
/** Base implementation of {@link MetricManager}. */
public abstract class AbstractMetricManager implements MetricManager {
@@ -149,12 +150,20 @@ public abstract class AbstractMetricManager implements
MetricManager {
});
}
- private MetricSet getMetricSet(String srcName) {
+ /**
+ * Get metric set that corresponds to provided source name.
+ *
+ * @param srcName Metric source name.
+ * @return MetricSet or {@code null} if source is disabled (e.g. it can be
registered, but disabled by default).
+ */
+ private @Nullable MetricSet getMetricSet(String srcName) {
return registry.snapshot().metrics().get(srcName);
}
- private void removeMetricSet(MetricSet metricSet) {
- enabledMetricExporters.values().forEach(e ->
e.removeMetricSet(metricSet));
+ private void removeMetricSet(@Nullable MetricSet metricSet) {
+ if (metricSet != null) {
+ enabledMetricExporters.values().forEach(e ->
e.removeMetricSet(metricSet));
+ }
}
@Override
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/BasePartitionTableStatsMetricTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/BasePartitionTableStatsMetricTest.java
new file mode 100644
index 00000000000..4dc2fc2c29e
--- /dev/null
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/BasePartitionTableStatsMetricTest.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.table;
+
+import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.Objects;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.catalog.Catalog;
+import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor;
+import org.apache.ignite.internal.catalog.descriptors.CatalogZoneDescriptor;
+import org.apache.ignite.internal.metrics.LongMetric;
+import org.apache.ignite.internal.metrics.MetricManager;
+import org.apache.ignite.internal.metrics.MetricSet;
+import org.apache.ignite.internal.sql.BaseSqlIntegrationTest;
+import
org.apache.ignite.internal.table.distributed.PartitionTableStatsMetricSource;
+import org.apache.ignite.table.QualifiedName;
+
+/**
+ * Base class for partition stats metrics tests.
+ */
+@SuppressWarnings("WeakerAccess")
+abstract class BasePartitionTableStatsMetricTest extends
BaseSqlIntegrationTest {
+
+ static final int UNDEFINED_METRIC_VALUE = -1;
+
+ static long metricFromAnyNode(String tableName, int partId, String
metricName) {
+ TableTuple table = TableTuple.of(tableName);
+
+ return metricFromAnyNode(table.id, partId, metricName);
+ }
+
+ static long metricFromAnyNode(int tableId, int partId, String metricName) {
+ for (int i = 0; i < CLUSTER.nodes().size(); i++) {
+ long value = metricFromNode(i, tableId, partId, metricName);
+
+ if (value != UNDEFINED_METRIC_VALUE) {
+ return value;
+ }
+ }
+
+ return UNDEFINED_METRIC_VALUE;
+ }
+
+ static long metricFromNode(int nodeIdx, int tableId, int partId, String
metricName) {
+ String metricSourceName =
+ PartitionTableStatsMetricSource.formatSourceName(tableId,
partId);
+
+ MetricManager metricManager =
unwrapIgniteImpl(node(nodeIdx)).metricManager();
+
+ MetricSet metrics =
metricManager.metricSnapshot().metrics().get(metricSourceName);
+
+ if (metrics != null) {
+ LongMetric metric = metrics.get(metricName);
+ Objects.requireNonNull(metric, "metric does not exist: " +
metricName);
+
+ return metric.value();
+ }
+
+ return UNDEFINED_METRIC_VALUE;
+ }
+
+ static void sqlScript(String... queries) {
+ CLUSTER.aliveNode().sql().executeScript(String.join(";", queries));
+ }
+
+ static void enableStats(String tableName) {
+ TableTuple table = TableTuple.of(tableName);
+
+ for (int p = 0; p < table.partsCount; p++) {
+ String metricName =
PartitionTableStatsMetricSource.formatSourceName(table.id, p);
+
+ for (int i = 0; i < CLUSTER.nodes().size(); i++) {
+ enableMetricSource(metricName, i);
+ }
+ }
+ }
+
+ static void enableMetricSource(String sourceName, int nodeIdx) {
+ IgniteImpl node = unwrapIgniteImpl(node(nodeIdx));
+ node.metricManager().metricSources().stream()
+ .filter(ms -> sourceName.equals(ms.name()))
+ .findAny()
+ .ifPresent(ms -> node.metricManager().enable(ms));
+ }
+
+ static final class TableTuple {
+ final int id;
+ final int partsCount;
+
+ TableTuple(int id, int partsCount) {
+ this.id = id;
+ this.partsCount = partsCount;
+ }
+
+ static TableTuple of(String tableName) {
+ QualifiedName qualifiedName = QualifiedName.parse(tableName);
+ Catalog catalog =
unwrapIgniteImpl(node(0)).catalogManager().latestCatalog();
+
+ CatalogTableDescriptor tableDesc =
catalog.table(qualifiedName.schemaName(), qualifiedName.objectName());
+ assertNotNull(tableDesc);
+
+ CatalogZoneDescriptor zoneDesc = catalog.zone(tableDesc.zoneId());
+ assertNotNull(zoneDesc);
+
+ int partsCount = zoneDesc.partitions();
+
+ return new TableTuple(tableDesc.id(), partsCount);
+ }
+ }
+}
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItPartitionTableStatsMetricConfigurationTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItPartitionTableStatsMetricConfigurationTest.java
index cdcd2ca1a92..3cd379d8b83 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItPartitionTableStatsMetricConfigurationTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItPartitionTableStatsMetricConfigurationTest.java
@@ -22,13 +22,13 @@ import static
org.apache.ignite.internal.lang.IgniteStringFormatter.format;
import static
org.apache.ignite.internal.table.ItPartitionTableStatsMetricTest.expectNextMilestone;
import org.apache.ignite.InitParametersBuilder;
-import org.apache.ignite.internal.sql.BaseSqlIntegrationTest;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Check that partition modification counter settings are depends on
configuration settings. */
-public class ItPartitionTableStatsMetricConfigurationTest extends
BaseSqlIntegrationTest {
+// TODO: Revisit test during https://issues.apache.org/jira/browse/IGNITE-28002
+public class ItPartitionTableStatsMetricConfigurationTest extends
BasePartitionTableStatsMetricTest {
private static final String ZONE_1_PART_NO_REPLICAS =
"zone_single_partition_no_replicas";
private static final int MIN_STALE_ROWS = 2;
private static final double STALE_ROWS_FRACTION = 1.0d;
@@ -67,6 +67,8 @@ public class ItPartitionTableStatsMetricConfigurationTest
extends BaseSqlIntegra
sql(format("INSERT INTO {} VALUES(0, 0), (1, 1);", tableName));
+ enableStats(tableName);
+
expectNextMilestone(tableName, 2 * MIN_STALE_ROWS);
sql(format("INSERT INTO {} VALUES(2, 2), (3, 3);", tableName));
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItPartitionTableStatsMetricTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItPartitionTableStatsMetricTest.java
index 8b547a05717..9ddf1451d8a 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItPartitionTableStatsMetricTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItPartitionTableStatsMetricTest.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.table;
-import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
import static
org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_MIN_STALE_ROWS_COUNT;
import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
import static
org.apache.ignite.internal.table.distributed.PartitionTableStatsMetricSource.METRIC_COUNTER;
@@ -26,20 +25,11 @@ import static
org.apache.ignite.internal.table.distributed.PartitionTableStatsMe
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Map;
-import java.util.Objects;
-import org.apache.ignite.internal.catalog.Catalog;
-import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor;
-import org.apache.ignite.internal.metrics.LongMetric;
-import org.apache.ignite.internal.metrics.MetricManager;
-import org.apache.ignite.internal.metrics.MetricSet;
-import org.apache.ignite.internal.sql.BaseSqlIntegrationTest;
import
org.apache.ignite.internal.table.distributed.PartitionModificationCounter;
import
org.apache.ignite.internal.table.distributed.PartitionTableStatsMetricSource;
import org.apache.ignite.table.KeyValueView;
-import org.apache.ignite.table.QualifiedName;
import org.apache.ignite.tx.Transaction;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.BeforeAll;
@@ -51,13 +41,12 @@ import org.junit.jupiter.api.Test;
*
* <p>Includes {@link PartitionModificationCounter partition modification
counter} metrics.
*/
-public class ItPartitionTableStatsMetricTest extends BaseSqlIntegrationTest {
+// TODO: Revisit test during https://issues.apache.org/jira/browse/IGNITE-28002
+public class ItPartitionTableStatsMetricTest extends
BasePartitionTableStatsMetricTest {
private static final String ZONE_1_PART_NO_REPLICAS =
"zone_single_partition_no_replicas";
private static final String ZONE_1_PART_REPLICAS = "zone_single_partition";
private static final String ZONE_8_PART_NO_REPLICAS =
"zone_multi_partition";
- private static final int UNDEFINED_METRIC_VALUE = -1;
-
@BeforeAll
void setupDistributionZones() {
sqlScript(
@@ -77,25 +66,27 @@ public class ItPartitionTableStatsMetricTest extends
BaseSqlIntegrationTest {
*/
@Test
void twoTablesInTheSameZone() {
- String tab1 = "T1";
- String tab2 = "T2";
+ String t1 = "T1";
+ String t2 = "T2";
sqlScript(
- format("CREATE TABLE {}(id INT PRIMARY KEY, val INT) ZONE
{};", tab1, ZONE_1_PART_NO_REPLICAS),
- format("CREATE TABLE {}(id INT PRIMARY KEY, val INT) ZONE
{};", tab2, ZONE_1_PART_NO_REPLICAS)
+ format("CREATE TABLE {}(id INT PRIMARY KEY, val INT) ZONE
{};", t1, ZONE_1_PART_NO_REPLICAS),
+ format("CREATE TABLE {}(id INT PRIMARY KEY, val INT) ZONE
{};", t2, ZONE_1_PART_NO_REPLICAS)
);
+ enableStats(t1);
+ enableStats(t2);
- sql(format("INSERT INTO {} VALUES(0, 0), (1, 1);", tab1));
+ sql(format("INSERT INTO {} VALUES(0, 0), (1, 1);", t1));
- expectModsCount(tab1, 2L);
- expectNextMilestone(tab1, DEFAULT_MIN_STALE_ROWS_COUNT);
+ expectModsCount(t1, 2L);
+ expectNextMilestone(t1, DEFAULT_MIN_STALE_ROWS_COUNT);
- sql(format("INSERT INTO {} VALUES(0, 0), (1, 1), (2, 2);", tab2));
+ sql(format("INSERT INTO {} VALUES(0, 0), (1, 1), (2, 2);", t2));
- expectModsCount(tab2, 3L);
- expectNextMilestone(tab2, DEFAULT_MIN_STALE_ROWS_COUNT);
+ expectModsCount(t2, 3L);
+ expectNextMilestone(t2, DEFAULT_MIN_STALE_ROWS_COUNT);
- expectModsCount(tab1, 2L);
+ expectModsCount(t1, 2L);
}
/**
@@ -107,18 +98,21 @@ public class ItPartitionTableStatsMetricTest extends
BaseSqlIntegrationTest {
sqlScript(
format("CREATE TABLE {}(id INT PRIMARY KEY, val INT) ZONE
{};", table, ZONE_1_PART_NO_REPLICAS),
- "INSERT INTO test_table VALUES(0, 0), (1, 1);"
+ format("INSERT INTO {} VALUES(0, 0), (1, 1);", table)
);
+ enableStats(table);
expectModsCount(table, 2);
sqlScript(
format("DROP TABLE {}", table),
format("CREATE TABLE {}(id INT PRIMARY KEY, val INT) ZONE
{};", table, ZONE_1_PART_NO_REPLICAS)
);
+ enableStats(table);
expectModsCount(table, 0);
- sql("INSERT INTO test_table VALUES(0, 0), (1, 1);");
+ sql(format("INSERT INTO {} VALUES(0, 0), (1, 1);", table));
expectModsCount(table, 2);
+
}
/**
@@ -126,91 +120,98 @@ public class ItPartitionTableStatsMetricTest extends
BaseSqlIntegrationTest {
*/
@Test
void differentUpdateTypes() {
- String tabName = "test_table";
- sql(format("CREATE TABLE {}(id INT PRIMARY KEY, val INT) ZONE {};",
tabName, ZONE_8_PART_NO_REPLICAS));
- KeyValueView<Integer, Integer> keyValueView =
CLUSTER.aliveNode().tables().table("test_table")
+ String table = "test_table";
+
+ sql(format("CREATE TABLE {}(id INT PRIMARY KEY, val INT) ZONE {};",
table, ZONE_8_PART_NO_REPLICAS));
+ enableStats(table);
+
+ KeyValueView<Integer, Integer> keyValueView =
CLUSTER.aliveNode().tables().table(table)
.keyValueView(Integer.class, Integer.class);
int expectedMods = 0;
// Implicit transaction.
{
- sql("INSERT INTO test_table VALUES(0, 0);");
- expectModsCount(tabName, ++expectedMods);
+ sql(format("INSERT INTO {} VALUES(0, 0);", table));
+ expectModsCount(table, ++expectedMods);
- sql("UPDATE test_table SET val=1 WHERE id=0");
- expectModsCount(tabName, ++expectedMods);
+ sql(format("UPDATE {} SET val=1 WHERE id=0", table));
+ expectModsCount(table, ++expectedMods);
keyValueView.put(null, 0, 2);
- expectModsCount(tabName, ++expectedMods);
+ expectModsCount(table, ++expectedMods);
- sql("INSERT INTO test_table VALUES(1, 1), (2, 2);");
+ sql(format("INSERT INTO {} VALUES(1, 1), (2, 2);", table));
expectedMods += 2;
- expectModsCount(tabName, expectedMods);
+ expectModsCount(table, expectedMods);
keyValueView.putAll(null, Map.of(3, 3, 4, 4, 5, 5));
expectedMods += 3;
- expectModsCount(tabName, expectedMods);
+ expectModsCount(table, expectedMods);
- sql("UPDATE test_table SET val=20 WHERE val = 2");
+ sql(format("UPDATE {} SET val=20 WHERE val=2", table));
expectedMods += 2;
- expectModsCount(tabName, expectedMods);
+ expectModsCount(table, expectedMods);
- sql("DELETE FROM test_table");
+ sql(format("DELETE FROM {}", table));
expectedMods += 6;
- expectModsCount(tabName, expectedMods);
+ expectModsCount(table, expectedMods);
}
// Explicit transaction.
{
{
Transaction tx = CLUSTER.aliveNode().transactions().begin();
- sql(tx, "INSERT INTO test_table VALUES(0, 0);");
- expectModsCount(tabName, expectedMods);
+
+ sql(tx, format("INSERT INTO {} VALUES(0, 0)", table));
+ expectModsCount(table, expectedMods);
+
tx.commit();
- expectModsCount(tabName, ++expectedMods);
+ expectModsCount(table, ++expectedMods);
}
{
Transaction tx = CLUSTER.aliveNode().transactions().begin();
- sql(tx, "UPDATE test_table SET val=1 WHERE id=0");
+ sql(tx, format("UPDATE {} SET val=1 WHERE id=0", table));
keyValueView.put(tx, 0, 2);
- sql(tx, "INSERT INTO test_table VALUES(1, 1), (2, 2);");
+
+ sql(tx, format("INSERT INTO {} VALUES(1, 1), (2, 2)", table));
keyValueView.putAll(tx, Map.of(3, 3, 4, 4, 5, 5));
- expectModsCount(tabName, expectedMods);
+
+ expectModsCount(table, expectedMods);
tx.commit();
expectedMods += 6;
- expectModsCount(tabName, expectedMods);
+ expectModsCount(table, expectedMods);
}
{
Transaction tx = CLUSTER.aliveNode().transactions().begin();
- sql(tx, "UPDATE test_table SET val=20 WHERE val = 2");
- sql(tx, "DELETE FROM test_table");
- expectModsCount(tabName, expectedMods);
+ sql(tx, format("UPDATE {} SET val=20 WHERE val=2", table));
+ sql(tx, format("DELETE FROM {}", table));
+ expectModsCount(table, expectedMods);
tx.commit();
expectedMods += 6;
- expectModsCount(tabName, expectedMods);
+ expectModsCount(table, expectedMods);
}
}
for (int part = 0; part < 8; part++) {
- assertThat(metricFromAnyNode(tabName, part,
METRIC_NEXT_MILESTONE), is(DEFAULT_MIN_STALE_ROWS_COUNT));
+ assertThat(metricFromAnyNode(table, part, METRIC_NEXT_MILESTONE),
is(DEFAULT_MIN_STALE_ROWS_COUNT));
}
+
}
/**
- * Tests that the milestone timestamp is updated only when
- * the number of modifications reaches the configured threshold.
+ * Tests that the milestone timestamp is updated only when the number of
modifications reaches the configured threshold.
*/
@Test
void reachMilestoneUpdateTest() {
- String tableWithReplicas = "TEST_TABLE";
- String tableNoReplicas = "TEST_TABLE_NO_REPLICAS";
+ String tableWithReplicas = "test_table";
+ String tableNoReplicas = "test_table_no_replicas";
int replicas = initialNodes();
@@ -220,6 +221,8 @@ public class ItPartitionTableStatsMetricTest extends
BaseSqlIntegrationTest {
format("INSERT INTO {} VALUES(0, 0);", tableWithReplicas),
format("INSERT INTO {} VALUES(0, 0);", tableNoReplicas)
);
+ enableStats(tableWithReplicas);
+ enableStats(tableNoReplicas);
expectModsCount(tableNoReplicas, 1);
expectModsCount(tableWithReplicas, replicas);
@@ -266,7 +269,8 @@ public class ItPartitionTableStatsMetricTest extends
BaseSqlIntegrationTest {
assertThat(metricFromAnyNode(tableNoReplicas, 0,
METRIC_LAST_MILESTONE_TIMESTAMP), greaterThan(initTsNoReplicas))
);
Awaitility.await().untilAsserted(() ->
- assertThat(metricFromAnyNode(tableWithReplicas, 0,
METRIC_LAST_MILESTONE_TIMESTAMP), greaterThan(initTsWithReplicas))
+ assertThat(metricFromAnyNode(tableWithReplicas, 0,
METRIC_LAST_MILESTONE_TIMESTAMP),
+ greaterThan(initTsWithReplicas))
);
Awaitility.await().untilAsserted(() ->
@@ -278,38 +282,24 @@ public class ItPartitionTableStatsMetricTest extends
BaseSqlIntegrationTest {
}
}
- private void expectModsCount(String tableName, long value) {
- expectLongValue(tableName, value, METRIC_COUNTER);
- }
-
- static void expectNextMilestone(String tableName, long value) {
- expectLongValue(tableName, value, METRIC_NEXT_MILESTONE);
- }
-
- private static void expectLongValue(String tableName, long value, String
metricName) {
- QualifiedName qualifiedName = QualifiedName.parse(tableName);
- Catalog catalog =
unwrapIgniteImpl(node(0)).catalogManager().latestCatalog();
- CatalogTableDescriptor tableDesc =
catalog.table(qualifiedName.schemaName(), qualifiedName.objectName());
- int partsCount = catalog.zone(tableDesc.zoneId()).partitions();
+ private static void expectAggregatedMetricValue(String tableName, long
value, String metricName) {
+ TableTuple table = TableTuple.of(tableName);
Awaitility.await().untilAsserted(() -> {
- long summaryValue = 0;
+ long aggregatedValue = 0;
- for (int part = 0; part < partsCount; part++) {
- int tableId = tableIdByName(QualifiedName.parse(tableName));
-
- String metricSourceName =
-
PartitionTableStatsMetricSource.formatSourceName(tableId, part);
+ for (int part = 0; part < table.partsCount; part++) {
+ String metricSourceName =
PartitionTableStatsMetricSource.formatSourceName(table.id, part);
boolean metricFound = false;
for (int i = 0; i < CLUSTER.nodes().size(); i++) {
- long metricValue = metricFromNode(i, tableName, part,
metricName);
+ long metricValue = metricFromNode(i, table.id, part,
metricName);
if (metricValue != UNDEFINED_METRIC_VALUE) {
metricFound = true;
- summaryValue += metricValue;
+ aggregatedValue += metricValue;
}
}
@@ -318,53 +308,15 @@ public class ItPartitionTableStatsMetricTest extends
BaseSqlIntegrationTest {
}
}
- assertThat(summaryValue, is(value));
+ assertThat(aggregatedValue, is(value));
});
}
- private static int tableIdByName(QualifiedName qualifiedName) {
- CatalogTableDescriptor tableDesc =
unwrapIgniteImpl(node(0)).catalogManager()
- .latestCatalog()
- .table(qualifiedName.schemaName(), qualifiedName.objectName());
-
- assertNotNull(tableDesc);
-
- return tableDesc.id();
- }
-
- private long metricFromAnyNode(String tableName, int partId, String
metricName) {
- for (int i = 0; i < CLUSTER.nodes().size(); i++) {
- long value = metricFromNode(i, tableName, partId, metricName);
-
- if (value != UNDEFINED_METRIC_VALUE) {
- return value;
- }
- }
-
- return UNDEFINED_METRIC_VALUE;
+ private static void expectModsCount(String tableName, long value) {
+ expectAggregatedMetricValue(tableName, value, METRIC_COUNTER);
}
- private static long metricFromNode(int nodeIdx, String tableName, int
partId, String metricName) {
- int tableId = tableIdByName(QualifiedName.parse(tableName));
-
- String metricSourceName =
- PartitionTableStatsMetricSource.formatSourceName(tableId,
partId);
-
- MetricManager metricManager =
unwrapIgniteImpl(node(nodeIdx)).metricManager();
-
- MetricSet metrics =
metricManager.metricSnapshot().metrics().get(metricSourceName);
-
- if (metrics != null) {
- LongMetric metric = metrics.get(metricName);
- Objects.requireNonNull(metric, "metric does not exist: " +
metricName);
-
- return metric.value();
- }
-
- return UNDEFINED_METRIC_VALUE;
- }
-
- private static void sqlScript(String ... queries) {
- CLUSTER.aliveNode().sql().executeScript(String.join(";", queries));
+ static void expectNextMilestone(String tableName, long value) {
+ expectAggregatedMetricValue(tableName, value, METRIC_NEXT_MILESTONE);
}
}
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
index eede201c39a..38adc3c3856 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
@@ -1657,8 +1657,9 @@ public class TableManager implements
IgniteTablesInternal, IgniteComponent {
new PartitionTableStatsMetricSource(table.tableId(),
partitionId, counter);
try {
+ // Only register this Metrics Source and do not enable it by
default
+ // as it is intended for online troubleshooting purposes only.
metricManager.registerSource(metricSource);
- metricManager.enable(metricSource);
TablePartitionId tablePartitionId = new
TablePartitionId(table.tableId(), partitionId);