This is an automated email from the ASF dual-hosted git repository.
namelchev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new c73c7c40d3f IGNITE-28408 Added Ignite version to the performance
statistics error message (#12960)
c73c7c40d3f is described below
commit c73c7c40d3f89193260d34e98378d00f6c2c87c2
Author: Aleksandr Chesnokov <[email protected]>
AuthorDate: Mon Apr 13 15:00:25 2026 +0300
IGNITE-28408 Added Ignite version to the performance statistics error
message (#12960)
---
.../FilePerformanceStatisticsReader.java | 23 +++++++++++---
.../FilePerformanceStatisticsWriter.java | 8 +++--
.../performancestatistics/OperationType.java | 4 ++-
.../SystemViewFileWriter.java | 2 ++
.../ForwardReadQueryPropertyTest.java | 35 ++++++++++++++++++----
.../performancestatistics/ForwardReadTest.java | 2 ++
.../PerformanceStatisticsPropertiesTest.java | 4 ++-
.../PerformanceStatisticsSystemViewTest.java | 2 ++
8 files changed, 67 insertions(+), 13 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/FilePerformanceStatisticsReader.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/FilePerformanceStatisticsReader.java
index 3f596cf6522..61f65019db9 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/FilePerformanceStatisticsReader.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/FilePerformanceStatisticsReader.java
@@ -50,6 +50,8 @@ import static java.nio.ByteBuffer.allocateDirect;
import static java.nio.ByteOrder.nativeOrder;
import static java.nio.file.Files.walkFileTree;
import static java.nio.file.StandardOpenOption.READ;
+import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
+import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.FILE_FORMAT_VERSION;
import static
org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_START;
import static
org.apache.ignite.internal.processors.performancestatistics.OperationType.CHECKPOINT;
import static
org.apache.ignite.internal.processors.performancestatistics.OperationType.JOB;
@@ -83,6 +85,9 @@ import static
org.apache.ignite.internal.processors.performancestatistics.Operat
* @see FilePerformanceStatisticsWriter
*/
public class FilePerformanceStatisticsReader {
+ /** Legacy format version without Ignite product version in header. */
+ static final short LEGACY_FILE_FORMAT_VERSION_1 = 1;
+
/** Default file read buffer size. */
private static final int DFLT_READ_BUFFER_SIZE = (int)(8 * U.MB);
@@ -229,14 +234,24 @@ public class FilePerformanceStatisticsReader {
throw new IgniteException("Unsupported file format");
if (opType == VERSION) {
- if (buf.remaining() < OperationType.versionRecordSize())
+ if (buf.remaining() < Short.BYTES)
return false;
short ver = buf.getShort();
+ String ignVer = null;
+
+ if (ver > LEGACY_FILE_FORMAT_VERSION_1) {
+ ForwardableString verStr = readString(buf);
+
+ if (verStr == null)
+ return false;
+
+ ignVer = verStr.str;
+ }
- if (ver != FilePerformanceStatisticsWriter.FILE_FORMAT_VERSION) {
- throw new IgniteException("Unsupported file format version
[fileVer=" + ver + ", supportedVer=" +
- FilePerformanceStatisticsWriter.FILE_FORMAT_VERSION + ']');
+ if (ver != FILE_FORMAT_VERSION && ver !=
LEGACY_FILE_FORMAT_VERSION_1) {
+ throw new IgniteException("Unsupported file format version
[igniteVer=" + ignVer + ", fileVer=" + ver +
+ "]. The reader version [readerIgniteVer=" + VER_STR + ",
readerFileVer=" + FILE_FORMAT_VERSION + ']');
}
return true;
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/FilePerformanceStatisticsWriter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/FilePerformanceStatisticsWriter.java
index 36f48e78546..4d757177d78 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/FilePerformanceStatisticsWriter.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/FilePerformanceStatisticsWriter.java
@@ -46,6 +46,7 @@ import org.apache.ignite.lang.IgniteUuid;
import static
org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_BUFFER_SIZE;
import static
org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_FILE_MAX_SIZE;
import static
org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_FLUSH_SIZE;
+import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
import static
org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_START;
import static
org.apache.ignite.internal.processors.performancestatistics.OperationType.CHECKPOINT;
import static
org.apache.ignite.internal.processors.performancestatistics.OperationType.JOB;
@@ -96,7 +97,7 @@ public class FilePerformanceStatisticsWriter {
* File format version. This version should be incremented each time when
format of existing events are
* changed (fields added/removed) to avoid unexpected non-informative
errors on deserialization.
*/
- public static final short FILE_FORMAT_VERSION = 1;
+ public static final short FILE_FORMAT_VERSION = 2;
/** File writer thread name. */
static final String WRITER_THREAD_NAME = "performance-statistics-writer";
@@ -155,7 +156,10 @@ public class FilePerformanceStatisticsWriter {
fileWriter = new FileWriter(ctx, log);
- doWrite(OperationType.VERSION, OperationType.versionRecordSize(), buf
-> buf.putShort(FILE_FORMAT_VERSION));
+ doWrite(OperationType.VERSION, OperationType.versionRecordSize(), buf
-> {
+ buf.putShort(FILE_FORMAT_VERSION);
+ writeString(buf, VER_STR, false);
+ });
}
/** Starts collecting performance statistics. */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/OperationType.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/OperationType.java
index 2f1f76d7661..612976ae1a3 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/OperationType.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/OperationType.java
@@ -23,6 +23,8 @@ import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
+import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
+
/**
* Performance statistics operation type.
*/
@@ -295,7 +297,7 @@ public enum OperationType {
/** @return Version record size. */
public static int versionRecordSize() {
- return Short.BYTES;
+ return Short.BYTES + 1 + Integer.BYTES + VER_STR.length();
}
/** @return Pages write throttle record size. */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/SystemViewFileWriter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/SystemViewFileWriter.java
index df975e18af5..04688302950 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/SystemViewFileWriter.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/SystemViewFileWriter.java
@@ -39,6 +39,7 @@ import org.jetbrains.annotations.Nullable;
import static
org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_BUFFER_SIZE;
import static
org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_FLUSH_SIZE;
+import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.DFLT_BUFFER_SIZE;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.DFLT_FLUSH_SIZE;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.FILE_FORMAT_VERSION;
@@ -112,6 +113,7 @@ class SystemViewFileWriter extends GridWorker {
doWrite(buf -> {
buf.put(OperationType.VERSION.id());
buf.putShort(FILE_FORMAT_VERSION);
+ writeString(buf, VER_STR, false);
});
}
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/ForwardReadQueryPropertyTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/ForwardReadQueryPropertyTest.java
index 1fe7f1e6eb2..5177bd9789f 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/ForwardReadQueryPropertyTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/ForwardReadQueryPropertyTest.java
@@ -20,7 +20,9 @@ package
org.apache.ignite.internal.processors.performancestatistics;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.ignite.internal.processors.cache.persistence.file.FileIO;
@@ -28,31 +30,48 @@ import
org.apache.ignite.internal.processors.cache.persistence.file.RandomAccess
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import static java.util.Collections.singletonList;
import static java.util.UUID.randomUUID;
+import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
+import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsReader.LEGACY_FILE_FORMAT_VERSION_1;
+import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.FILE_FORMAT_VERSION;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.PERF_STAT_DIR;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.writeString;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.writeUuid;
+import static org.junit.runners.Parameterized.Parameter;
+import static org.junit.runners.Parameterized.Parameters;
/**
* Tests forward read mode for {@link OperationType#QUERY_PROPERTY} records.
*/
+@RunWith(Parameterized.class)
public class ForwardReadQueryPropertyTest extends
AbstractPerformanceStatisticsTest {
/** Read buffer size. */
private static final int BUFFER_SIZE = 100;
+ /** File format version. */
+ @Parameter
+ public short fileFormatVer;
+
+ /** @return Test parameters. */
+ @Parameters(name = "fileFormatVer={0}")
+ public static Collection<?> parameters() {
+ return List.of(FILE_FORMAT_VERSION, LEGACY_FILE_FORMAT_VERSION_1);
+ }
+
/** @throws Exception If failed. */
@Test
public void testStringForwardRead() throws Exception {
File dir = U.resolveWorkDirectory(U.defaultWorkDirectory(),
PERF_STAT_DIR, false);
- Map<String, String> expProps = createStatistics(dir);
+ Map<String, String> expProps = createStatistics(dir, fileFormatVer);
Map<String, String> actualProps = new HashMap<>();
new FilePerformanceStatisticsReader(BUFFER_SIZE, new TestHandler() {
- @Override public void queryProperty(UUID nodeId,
GridCacheQueryType type, UUID qryNodeId, long id, String name,
- String val) {
+ @Override public void queryProperty(UUID nodeId,
GridCacheQueryType type, UUID qryNodeId, long id, String name, String val) {
assertNotNull(name);
assertNotNull(val);
@@ -64,14 +83,20 @@ public class ForwardReadQueryPropertyTest extends
AbstractPerformanceStatisticsT
}
/** Creates test performance statistics file. */
- private Map<String, String> createStatistics(File dir) throws Exception {
+ private Map<String, String> createStatistics(File dir, short
fileFormatVer) throws Exception {
File file = new File(dir, "node-" + randomUUID() + ".prf");
try (FileIO fileIo = new RandomAccessFileIOFactory().create(file)) {
ByteBuffer buf =
ByteBuffer.allocate(1024).order(ByteOrder.nativeOrder());
buf.put(OperationType.VERSION.id());
- buf.putShort(FilePerformanceStatisticsWriter.FILE_FORMAT_VERSION);
+
+ if (fileFormatVer == FILE_FORMAT_VERSION) {
+ buf.putShort(fileFormatVer);
+ writeString(buf, VER_STR, false);
+ }
+ else
+ buf.putShort(fileFormatVer);
writeQueryProperty(buf, "property", true, "val", true);
writeQueryProperty(buf, "property", false, "val", false);
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/ForwardReadTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/ForwardReadTest.java
index c5c2238e134..b01efaa4fd2 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/ForwardReadTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/ForwardReadTest.java
@@ -39,6 +39,7 @@ import static
com.google.common.collect.Collections2.permutations;
import static com.google.common.collect.Lists.cartesianProduct;
import static java.util.Collections.singletonList;
import static java.util.UUID.randomUUID;
+import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.PERF_STAT_DIR;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.writeIgniteUuid;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.writeString;
@@ -93,6 +94,7 @@ public class ForwardReadTest extends
AbstractPerformanceStatisticsTest {
buf.put(OperationType.VERSION.id());
buf.putShort(FilePerformanceStatisticsWriter.FILE_FORMAT_VERSION);
+ writeString(buf, VER_STR, false);
expTasks = writeData(buf);
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsPropertiesTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsPropertiesTest.java
index 6f53f6145e4..ab99820619c 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsPropertiesTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsPropertiesTest.java
@@ -113,7 +113,9 @@ public class PerformanceStatisticsPropertiesTest extends
AbstractPerformanceStat
@Test
@WithSystemProperty(key = IGNITE_PERF_STAT_FLUSH_SIZE, value = "" +
TEST_FLUSH_SIZE)
public void testFlushSize() throws Exception {
- long initLen =
srv.context().cache().cacheDescriptors().values().stream().mapToInt(
+ long initLen = 1 + OperationType.versionRecordSize();
+
+ initLen +=
srv.context().cache().cacheDescriptors().values().stream().mapToInt(
desc -> 1 +
cacheStartRecordSize(desc.cacheName().getBytes().length, false)).sum();
long opsCnt = (TEST_FLUSH_SIZE - initLen) / (/*typeOp*/1 +
OperationType.cacheRecordSize());
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsSystemViewTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsSystemViewTest.java
index 728bfa89a68..d8da170bb8f 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsSystemViewTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsSystemViewTest.java
@@ -41,6 +41,7 @@ import org.junit.Test;
import static java.util.UUID.randomUUID;
import static java.util.function.Function.identity;
+import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
import static
org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.METASTORE_VIEW;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.PERF_STAT_DIR;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.writeString;
@@ -197,6 +198,7 @@ public class PerformanceStatisticsSystemViewTest extends
AbstractPerformanceStat
buf.put(OperationType.VERSION.id());
buf.putShort(FilePerformanceStatisticsWriter.FILE_FORMAT_VERSION);
+ writeString(buf, VER_STR, false);
writeSystemView(buf, "customView", "customWalker", null);