Skip to content

Commit 89417c2

Browse files
committed
IGNITE-28408 PerfStat: Add Ignite version to prf file name
1 parent f456f59 commit 89417c2

File tree

7 files changed

+19
-7
lines changed

7 files changed

+19
-7
lines changed

modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/FilePerformanceStatisticsReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public class FilePerformanceStatisticsReader {
9191
"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}";
9292

9393
/** File name pattern. */
94-
private static final Pattern FILE_NODE_ID_PATTERN = Pattern.compile("^node-(" + UUID_STR_PATTERN + ")[^.]*\\.prf$");
94+
private static final Pattern FILE_NODE_ID_PATTERN = Pattern.compile("^node-(" + UUID_STR_PATTERN + ").*\\.prf$");
9595

9696
/** No-op handler. */
9797
private static final PerformanceStatisticsHandler[] NOOP_HANDLER = {};

modules/core/src/main/java/org/apache/ignite/internal/processors/performancestatistics/FilePerformanceStatisticsWriter.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import static org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_BUFFER_SIZE;
4747
import static org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_FILE_MAX_SIZE;
4848
import static org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_FLUSH_SIZE;
49+
import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
4950
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.CACHE_START;
5051
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.CHECKPOINT;
5152
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.JOB;
@@ -92,6 +93,9 @@ public class FilePerformanceStatisticsWriter {
9293
/** Default maximum cached strings threshold. String caching will stop on threshold excess. */
9394
public static final int DFLT_CACHED_STRINGS_THRESHOLD = 10 * 1024;
9495

96+
/** Ignite version marker in performance statistics file names. */
97+
private static final String IGNITE_VERSION_FILE_SUFFIX = "-v" + VER_STR;
98+
9599
/**
96100
* File format version. This version should be incremented each time when format of existing events are
97101
* changed (fields added/removed) to avoid unexpected non-informative errors on deserialization.
@@ -486,14 +490,16 @@ static File resolveStatisticsFile(GridKernalContext ctx, String fileName) throws
486490

487491
File fileDir = U.resolveWorkDirectory(igniteWorkDir, PERF_STAT_DIR, false);
488492

489-
File file = new File(fileDir, fileName + ".prf");
493+
String statisticsFileName = fileName + IGNITE_VERSION_FILE_SUFFIX;
494+
495+
File file = new File(fileDir, statisticsFileName + ".prf");
490496

491497
int idx = 0;
492498

493499
while (file.exists()) {
494500
idx++;
495501

496-
file = new File(fileDir, fileName + '-' + idx + ".prf");
502+
file = new File(fileDir, statisticsFileName + '-' + idx + ".prf");
497503
}
498504

499505
return file;

modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/AbstractPerformanceStatisticsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public static void waitForStatisticsEnabled(boolean performanceStatsEnabled) thr
133133
*/
134134
public static List<File> systemViewStatisticsFiles(List<File> files) {
135135
return files.stream()
136-
.filter(file1 -> file1.getName().matches("node-.*-system-views(-\\d+)?\\.prf"))
136+
.filter(file1 -> file1.getName().matches("node-.*-system-views-v[^-]+(?:-[^-]+)*(-\\d+)?\\.prf"))
137137
.collect(Collectors.toList());
138138
}
139139

modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/ForwardReadQueryPropertyTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import static java.util.Collections.singletonList;
3333
import static java.util.UUID.randomUUID;
34+
import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
3435
import static org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.PERF_STAT_DIR;
3536
import static org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.writeString;
3637
import static org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.writeUuid;
@@ -65,7 +66,7 @@ public void testStringForwardRead() throws Exception {
6566

6667
/** Creates test performance statistics file. */
6768
private Map<String, String> createStatistics(File dir) throws Exception {
68-
File file = new File(dir, "node-" + randomUUID() + ".prf");
69+
File file = new File(dir, "node-" + randomUUID() + "-v" + VER_STR + ".prf");
6970

7071
try (FileIO fileIo = new RandomAccessFileIOFactory().create(file)) {
7172
ByteBuffer buf = ByteBuffer.allocate(1024).order(ByteOrder.nativeOrder());

modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/ForwardReadTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import static com.google.common.collect.Lists.cartesianProduct;
4040
import static java.util.Collections.singletonList;
4141
import static java.util.UUID.randomUUID;
42+
import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
4243
import static org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.PERF_STAT_DIR;
4344
import static org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.writeIgniteUuid;
4445
import static org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.writeString;
@@ -86,7 +87,7 @@ public void testStringForwardRead() throws Exception {
8687
private Map<String, Integer> createStatistics(File dir) throws Exception {
8788
Map<String, Integer> expTasks;
8889

89-
File file = new File(dir, "node-" + randomUUID() + ".prf");
90+
File file = new File(dir, "node-" + randomUUID() + "-v" + VER_STR + ".prf");
9091

9192
try (FileIO fileIo = new RandomAccessFileIOFactory().create(file)) {
9293
ByteBuffer buf = ByteBuffer.allocate(10 * 1024).order(ByteOrder.nativeOrder());

modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsMultipleStartTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import org.apache.ignite.internal.IgniteEx;
2626
import org.junit.Test;
2727

28+
import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
29+
2830
/**
2931
* Tests performance statistics multiple start.
3032
*/
@@ -65,6 +67,7 @@ public void testStartCreateNewFile() throws Exception {
6567

6668
assertEquals(i, performanceStatisticsFiles(files).size());
6769
assertEquals(i, systemViewStatisticsFiles(files).size());
70+
assertTrue(files.stream().allMatch(file -> file.getName().contains("-v" + VER_STR)));
6871
}
6972
}
7073
}

modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsSystemViewTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import static java.util.UUID.randomUUID;
4343
import static java.util.function.Function.identity;
44+
import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
4445
import static org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.METASTORE_VIEW;
4546
import static org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.PERF_STAT_DIR;
4647
import static org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.writeString;
@@ -190,7 +191,7 @@ public void testCustomEmptySystemView() throws Exception {
190191

191192
/** Creates test performance statistics file. */
192193
private List<String> createStatistics(File dir) throws Exception {
193-
File file = new File(dir, "node-" + randomUUID() + ".prf");
194+
File file = new File(dir, "node-" + randomUUID() + "-v" + VER_STR + ".prf");
194195

195196
try (FileIO fileIo = new RandomAccessFileIOFactory().create(file)) {
196197
ByteBuffer buf = ByteBuffer.allocate(1024).order(ByteOrder.nativeOrder());

0 commit comments

Comments
 (0)