This is an automated email from the ASF dual-hosted git repository.
apolovtsev 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 ffe5031699b IGNITE-27850 Introduce FileProperties for file
identification in segstore (#7594)
ffe5031699b is described below
commit ffe5031699b882f41c5573a51263a68513591ea8
Author: Alexander Polovtcev <[email protected]>
AuthorDate: Mon Feb 16 10:19:39 2026 +0200
IGNITE-27850 Introduce FileProperties for file identification in segstore
(#7594)
---
...SegmentFilePointer.java => FileProperties.java} | 45 +++++--
.../raft/storage/segstore/IndexFileManager.java | 83 +++++++-----
.../raft/storage/segstore/IndexFileMeta.java | 22 +--
.../raft/storage/segstore/IndexFileMetaArray.java | 2 +-
.../raft/storage/segstore/RaftLogCheckpointer.java | 2 +-
.../raft/storage/segstore/SegmentFile.java | 43 +++++-
.../raft/storage/segstore/SegmentFileManager.java | 55 +++-----
.../raft/storage/segstore/SegmentFilePointer.java | 14 +-
.../storage/segstore/SegmentPayloadParser.java | 4 +-
.../raft/storage/segstore/GroupIndexMetaTest.java | 43 +++---
.../storage/segstore/IndexFileManagerTest.java | 148 ++++++++++-----------
.../storage/segstore/IndexFileMetaArrayTest.java | 30 ++---
.../storage/segstore/RaftLogCheckpointerTest.java | 2 +-
.../storage/segstore/SegmentFileManagerTest.java | 12 +-
.../raft/storage/segstore/SegmentFileTest.java | 2 +-
.../raft/storage/segstore/SyncSegmentFileTest.java | 2 +-
16 files changed, 275 insertions(+), 234 deletions(-)
diff --git
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFilePointer.java
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/FileProperties.java
similarity index 52%
copy from
modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFilePointer.java
copy to
modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/FileProperties.java
index 57c967c47b1..0fc9647903b 100644
---
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFilePointer.java
+++
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/FileProperties.java
@@ -19,22 +19,39 @@ package org.apache.ignite.internal.raft.storage.segstore;
import org.apache.ignite.internal.tostring.S;
-class SegmentFilePointer {
- private final int fileOrdinal;
+/**
+ * Represents properties common for some file types (namely Segment and Index
files) used by the log storage.
+ */
+class FileProperties {
+ /** File ordinal. Incremented each time a new file is created. */
+ private final int ordinal;
+
+ /** File generation. Incremented each time an existing file is compressed
by the Raft Log Garbage Collector. */
+ private final int generation;
+
+ FileProperties(int ordinal) {
+ this(ordinal, 0);
+ }
- private final int payloadOffset;
+ FileProperties(int ordinal, int generation) {
+ if (ordinal < 0) {
+ throw new IllegalArgumentException("Invalid file ordinal: " +
ordinal);
+ }
+
+ if (generation < 0) {
+ throw new IllegalArgumentException("Invalid file generation: " +
generation);
+ }
- SegmentFilePointer(int fileOrdinal, int payloadOffset) {
- this.fileOrdinal = fileOrdinal;
- this.payloadOffset = payloadOffset;
+ this.ordinal = ordinal;
+ this.generation = generation;
}
- int fileOrdinal() {
- return fileOrdinal;
+ int ordinal() {
+ return ordinal;
}
- int payloadOffset() {
- return payloadOffset;
+ int generation() {
+ return generation;
}
@Override
@@ -43,14 +60,14 @@ class SegmentFilePointer {
return false;
}
- SegmentFilePointer that = (SegmentFilePointer) o;
- return fileOrdinal == that.fileOrdinal && payloadOffset ==
that.payloadOffset;
+ FileProperties that = (FileProperties) o;
+ return ordinal == that.ordinal && generation == that.generation;
}
@Override
public int hashCode() {
- int result = fileOrdinal;
- result = 31 * result + payloadOffset;
+ int result = ordinal;
+ result = 31 * result + generation;
return result;
}
diff --git
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileManager.java
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileManager.java
index 5eadecc6e75..f5bb44f8635 100644
---
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileManager.java
+++
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileManager.java
@@ -172,17 +172,26 @@ class IndexFileManager {
*
* <p>Must only be called by the checkpoint thread.
*/
- Path saveIndexMemtable(ReadModeIndexMemTable indexMemTable) throws
IOException {
- return saveIndexMemtable(indexMemTable, ++curFileOrdinal, false);
+ Path saveNewIndexMemtable(ReadModeIndexMemTable indexMemTable) throws
IOException {
+ var newFileProperties = new FileProperties(++curFileOrdinal);
+
+ return saveIndexMemtable(indexMemTable, newFileProperties, false);
}
- private Path saveIndexMemtable(ReadModeIndexMemTable indexMemTable, int
fileOrdinal, boolean onRecovery) throws IOException {
- String fileName = indexFileName(fileOrdinal, 0);
+ private Path saveIndexMemtable(
+ ReadModeIndexMemTable indexMemTable,
+ FileProperties fileProperties,
+ boolean onRecovery
+ ) throws IOException {
+ String fileName = indexFileName(fileProperties);
Path tmpFilePath = indexFilesDir.resolve(fileName + TMP_FILE_SUFFIX);
+ assert !Files.exists(indexFilesDir.resolve(fileName)) : "Index file
already exists: " + fileName;
+ assert !Files.exists(tmpFilePath) : "Temporary index file already
exists: " + tmpFilePath;
+
try (var os = new
BufferedOutputStream(Files.newOutputStream(tmpFilePath, CREATE_NEW, WRITE))) {
- byte[] headerBytes = serializeHeaderAndFillMetadata(indexMemTable,
fileOrdinal, onRecovery);
+ byte[] headerBytes = serializeHeaderAndFillMetadata(indexMemTable,
fileProperties, onRecovery);
os.write(headerBytes);
@@ -205,8 +214,8 @@ class IndexFileManager {
* This method is intended to be called during {@link SegmentFileManager}
recovery in order to create index files that may have been
* lost due to a component stop before a checkpoint was able to complete.
*/
- void recoverIndexFile(ReadModeIndexMemTable indexMemTable, int
fileOrdinal) throws IOException {
- saveIndexMemtable(indexMemTable, fileOrdinal, true);
+ void recoverIndexFile(ReadModeIndexMemTable indexMemTable, FileProperties
fileProperties) throws IOException {
+ saveIndexMemtable(indexMemTable, fileProperties, true);
}
/**
@@ -227,7 +236,7 @@ class IndexFileManager {
return null;
}
- Path indexFile =
indexFilesDir.resolve(indexFileName(indexFileMeta.indexFileOrdinal(), 0));
+ Path indexFile =
indexFilesDir.resolve(indexFileName(indexFileMeta.indexFileProperties()));
// Index file payload is a 0-based array, which indices correspond to
the [fileMeta.firstLogIndex, fileMeta.lastLogIndex) range.
long payloadArrayIndex = logIndex -
indexFileMeta.firstLogIndexInclusive();
@@ -251,7 +260,7 @@ class IndexFileManager {
int segmentPayloadOffset = segmentPayloadOffsetBuffer.getInt(0);
- return new SegmentFilePointer(indexFileMeta.indexFileOrdinal(),
segmentPayloadOffset);
+ return new SegmentFilePointer(indexFileMeta.indexFileProperties(),
segmentPayloadOffset);
}
}
@@ -273,11 +282,15 @@ class IndexFileManager {
return groupIndexMeta == null ? -1 :
groupIndexMeta.lastLogIndexExclusive();
}
- boolean indexFileExists(int fileOrdinal) {
- return Files.exists(indexFilesDir.resolve(indexFileName(fileOrdinal,
0)));
+ boolean indexFileExists(FileProperties fileProperties) {
+ return Files.exists(indexFilePath(fileProperties));
+ }
+
+ Path indexFilePath(FileProperties fileProperties) {
+ return indexFilesDir.resolve(indexFileName(fileProperties));
}
- private byte[] serializeHeaderAndFillMetadata(ReadModeIndexMemTable
indexMemTable, int fileOrdinal, boolean onRecovery) {
+ private byte[] serializeHeaderAndFillMetadata(ReadModeIndexMemTable
indexMemTable, FileProperties fileProperties, boolean onRecovery) {
int numGroups = indexMemTable.numGroups();
int headerSize = headerSize(numGroups);
@@ -310,7 +323,7 @@ class IndexFileManager {
// (see recoverIndexFileMetas).
if (!onRecovery) {
IndexFileMeta indexFileMeta = createIndexFileMeta(
- firstLogIndexInclusive, lastLogIndexExclusive,
firstIndexKept, payloadOffset, fileOrdinal
+ firstLogIndexInclusive, lastLogIndexExclusive,
firstIndexKept, payloadOffset, fileProperties
);
putIndexFileMeta(groupId, indexFileMeta, firstIndexKept);
@@ -335,7 +348,7 @@ class IndexFileManager {
long lastLogIndexExclusive,
long firstIndexKept,
int payloadOffset,
- int fileOrdinal
+ FileProperties fileProperties
) {
if (firstLogIndexInclusive == -1) {
assert firstIndexKept != -1 : "Expected a prefix tombstone, but
firstIndexKept is not set.";
@@ -346,7 +359,7 @@ class IndexFileManager {
if (firstIndexKept == -1 || firstIndexKept <= firstLogIndexInclusive) {
// No prefix truncation required, simply create a new meta.
- return new IndexFileMeta(firstLogIndexInclusive,
lastLogIndexExclusive, payloadOffset, fileOrdinal);
+ return new IndexFileMeta(firstLogIndexInclusive,
lastLogIndexExclusive, payloadOffset, fileProperties);
}
// Create a meta with a truncated prefix.
@@ -354,7 +367,7 @@ class IndexFileManager {
int adjustedPayloadOffset = payloadOffset + numEntriesToSkip *
SEGMENT_FILE_OFFSET_SIZE;
- return new IndexFileMeta(firstIndexKept, lastLogIndexExclusive,
adjustedPayloadOffset, fileOrdinal);
+ return new IndexFileMeta(firstIndexKept, lastLogIndexExclusive,
adjustedPayloadOffset, fileProperties);
}
private void putIndexFileMeta(Long groupId, @Nullable IndexFileMeta
indexFileMeta, long firstIndexKept) {
@@ -400,47 +413,50 @@ class IndexFileManager {
return segmentInfo.size() * Integer.BYTES;
}
- private static String indexFileName(int fileOrdinal, int generation) {
- return String.format(INDEX_FILE_NAME_FORMAT, fileOrdinal, generation);
+ private static String indexFileName(FileProperties fileProperties) {
+ return String.format(INDEX_FILE_NAME_FORMAT, fileProperties.ordinal(),
fileProperties.generation());
}
- private void recoverIndexFileMetas(Path indexFile) throws IOException {
- int fileOrdinal = indexFileOrdinal(indexFile);
+ private void recoverIndexFileMetas(Path indexFilePath) throws IOException {
+ FileProperties fileProperties = indexFileProperties(indexFilePath);
- if (curFileOrdinal >= 0 && fileOrdinal != curFileOrdinal + 1) {
+ if (curFileOrdinal >= 0 && fileProperties.ordinal() != curFileOrdinal
+ 1) {
throw new IllegalStateException(String.format(
"Unexpected index file ordinal. Expected %d, actual %d
(%s).",
- curFileOrdinal + 1, fileOrdinal, indexFile
+ curFileOrdinal + 1, fileProperties.ordinal(), indexFilePath
));
}
- curFileOrdinal = fileOrdinal;
+ curFileOrdinal = fileProperties.ordinal();
- try (InputStream is = new
BufferedInputStream(Files.newInputStream(indexFile, StandardOpenOption.READ))) {
- ByteBuffer commonMetaBuffer = readBytes(is, COMMON_META_SIZE,
indexFile);
+ try (InputStream is = new
BufferedInputStream(Files.newInputStream(indexFilePath,
StandardOpenOption.READ))) {
+ ByteBuffer commonMetaBuffer = readBytes(is, COMMON_META_SIZE,
indexFilePath);
int magicNumber = commonMetaBuffer.getInt();
if (magicNumber != MAGIC_NUMBER) {
- throw new IllegalStateException(String.format("Invalid magic
number in index file %s: %d.", indexFile, magicNumber));
+ throw new IllegalStateException(String.format("Invalid magic
number in index file %s: %d.", indexFilePath, magicNumber));
}
int formatVersion = commonMetaBuffer.getInt();
if (formatVersion > FORMAT_VERSION) {
throw new IllegalStateException(String.format(
- "Unsupported format version in index file %s: %d.",
indexFile, formatVersion
+ "Unsupported format version in index file %s: %d.",
indexFilePath, formatVersion
));
}
int numGroups = commonMetaBuffer.getInt();
if (numGroups <= 0) {
- throw new IllegalStateException(String.format("Unexpected
number of groups in index file %s: %d.", indexFile, numGroups));
+ throw new IllegalStateException(String.format(
+ "Unexpected number of groups in index file %s: %d.",
+ indexFilePath, numGroups
+ ));
}
for (int i = 0; i < numGroups; i++) {
- ByteBuffer groupMetaBuffer = readBytes(is, GROUP_META_SIZE,
indexFile);
+ ByteBuffer groupMetaBuffer = readBytes(is, GROUP_META_SIZE,
indexFilePath);
long groupId = groupMetaBuffer.getLong();
groupMetaBuffer.getInt(); // Skip flags.
@@ -450,7 +466,7 @@ class IndexFileManager {
long firstIndexKept = groupMetaBuffer.getLong();
IndexFileMeta indexFileMeta = createIndexFileMeta(
- firstLogIndexInclusive, lastLogIndexExclusive,
firstIndexKept, payloadOffset, fileOrdinal
+ firstLogIndexInclusive, lastLogIndexExclusive,
firstIndexKept, payloadOffset, fileProperties
);
putIndexFileMeta(groupId, indexFileMeta, firstIndexKept);
@@ -458,7 +474,7 @@ class IndexFileManager {
}
}
- private static int indexFileOrdinal(Path indexFile) {
+ private static FileProperties indexFileProperties(Path indexFile) {
String fileName = indexFile.getFileName().toString();
Matcher matcher = INDEX_FILE_NAME_PATTERN.matcher(fileName);
@@ -467,7 +483,10 @@ class IndexFileManager {
throw new IllegalArgumentException(String.format("Invalid index
file name format: %s.", indexFile));
}
- return Integer.parseInt(matcher.group("ordinal"));
+ return new FileProperties(
+ Integer.parseInt(matcher.group("ordinal")),
+ Integer.parseInt(matcher.group("generation"))
+ );
}
private static ByteBuffer readBytes(InputStream is, int size, Path
indexFile) throws IOException {
diff --git
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMeta.java
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMeta.java
index f75cc00ba1d..10bd62f0d61 100644
---
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMeta.java
+++
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMeta.java
@@ -31,9 +31,9 @@ class IndexFileMeta {
private final int indexFilePayloadOffset;
- private final int indexFileOrdinal;
+ private final FileProperties indexFileProperties;
- IndexFileMeta(long firstLogIndexInclusive, long lastLogIndexExclusive, int
indexFilePayloadOffset, int indexFileOrdinal) {
+ IndexFileMeta(long firstLogIndexInclusive, long lastLogIndexExclusive, int
indexFilePayloadOffset, FileProperties indexFileProperties) {
assert firstLogIndexInclusive >= 0 : "Invalid first log index: " +
firstLogIndexInclusive;
assert lastLogIndexExclusive >= 0 : "Invalid first log index: " +
firstLogIndexInclusive;
@@ -41,14 +41,10 @@ class IndexFileMeta {
throw new IllegalArgumentException("Invalid log index range: [" +
firstLogIndexInclusive + ", " + lastLogIndexExclusive + ").");
}
- if (indexFileOrdinal < 0) {
- throw new IllegalArgumentException("Invalid index file ordinal: "
+ indexFileOrdinal);
- }
-
this.firstLogIndexInclusive = firstLogIndexInclusive;
this.lastLogIndexExclusive = lastLogIndexExclusive;
this.indexFilePayloadOffset = indexFilePayloadOffset;
- this.indexFileOrdinal = indexFileOrdinal;
+ this.indexFileProperties = indexFileProperties;
}
/**
@@ -72,11 +68,8 @@ class IndexFileMeta {
return indexFilePayloadOffset;
}
- /**
- * Returns the ordinal of the index file.
- */
- int indexFileOrdinal() {
- return indexFileOrdinal;
+ FileProperties indexFileProperties() {
+ return indexFileProperties;
}
/**
@@ -95,8 +88,7 @@ class IndexFileMeta {
IndexFileMeta that = (IndexFileMeta) o;
return firstLogIndexInclusive == that.firstLogIndexInclusive &&
lastLogIndexExclusive == that.lastLogIndexExclusive
- && indexFilePayloadOffset == that.indexFilePayloadOffset
- && indexFileOrdinal == that.indexFileOrdinal;
+ && indexFilePayloadOffset == that.indexFilePayloadOffset &&
indexFileProperties.equals(that.indexFileProperties);
}
@Override
@@ -104,7 +96,7 @@ class IndexFileMeta {
int result = Long.hashCode(firstLogIndexInclusive);
result = 31 * result + Long.hashCode(lastLogIndexExclusive);
result = 31 * result + indexFilePayloadOffset;
- result = 31 * result + indexFileOrdinal;
+ result = 31 * result + indexFileProperties.hashCode();
return result;
}
diff --git
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMetaArray.java
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMetaArray.java
index 8d74c8f267d..46b9ffc5df8 100644
---
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMetaArray.java
+++
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMetaArray.java
@@ -146,7 +146,7 @@ class IndexFileMetaArray {
firstLogIndexKept,
metaToUpdate.lastLogIndexExclusive(),
adjustedPayloadOffset,
- metaToUpdate.indexFileOrdinal()
+ metaToUpdate.indexFileProperties()
);
// Create a new array: the trimmed meta becomes the first element,
other elements with "firstLogIndexInclusive" larger
diff --git
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogCheckpointer.java
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogCheckpointer.java
index debe9f4b686..5913044052b 100644
---
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogCheckpointer.java
+++
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogCheckpointer.java
@@ -155,7 +155,7 @@ class RaftLogCheckpointer {
segmentFile.sync();
- indexFileManager.saveIndexMemtable(entry.memTable());
+ indexFileManager.saveNewIndexMemtable(entry.memTable());
queue.removeHead();
} catch (InterruptedException | ClosedByInterruptException e) {
diff --git
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFile.java
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFile.java
index 535a54f7eab..86ed55fac0b 100644
---
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFile.java
+++
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFile.java
@@ -26,6 +26,8 @@ import java.nio.channels.FileChannel.MapMode;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.ignite.internal.close.ManuallyCloseable;
import org.jetbrains.annotations.Nullable;
@@ -47,11 +49,19 @@ class SegmentFile implements ManuallyCloseable {
private static final MappedByteBufferSyncer SYNCER =
MappedByteBufferSyncer.createSyncer();
+ private static final String SEGMENT_FILE_NAME_FORMAT =
"segment-%010d-%010d.bin";
+
+ private static final Pattern SEGMENT_FILE_NAME_PATTERN =
Pattern.compile("segment-(?<ordinal>\\d{10})-(?<generation>\\d{10})\\.bin");
+
private final MappedByteBuffer buffer;
/** Flag indicating if an fsync call should follow every write to the
buffer. */
private final boolean isSync;
+ private final Path path;
+
+ private final FileProperties fileProperties;
+
/** Position of the first non-reserved byte in the buffer. */
private final AtomicInteger bufferPosition = new AtomicInteger();
@@ -67,11 +77,13 @@ class SegmentFile implements ManuallyCloseable {
/** Lock used to atomically execute fsync. */
private final Object syncLock = new Object();
- private SegmentFile(RandomAccessFile file, boolean isSync) throws
IOException {
+ private SegmentFile(RandomAccessFile file, Path path, boolean isSync)
throws IOException {
//noinspection ChannelOpenedButNotSafelyClosed
buffer = file.getChannel().map(MapMode.READ_WRITE, 0, file.length());
+ this.path = path;
this.isSync = isSync;
+ this.fileProperties = fileProperties(path);
}
static SegmentFile createNew(Path path, long fileSize, boolean isSync)
throws IOException {
@@ -88,7 +100,7 @@ class SegmentFile implements ManuallyCloseable {
try (var file = new RandomAccessFile(path.toFile(), "rw")) {
file.setLength(fileSize);
- return new SegmentFile(file, isSync);
+ return new SegmentFile(file, path, isSync);
}
}
@@ -98,10 +110,35 @@ class SegmentFile implements ManuallyCloseable {
}
try (var file = new RandomAccessFile(path.toFile(), "rw")) {
- return new SegmentFile(file, isSync);
+ return new SegmentFile(file, path, isSync);
}
}
+ static String fileName(FileProperties fileProperties) {
+ return String.format(SEGMENT_FILE_NAME_FORMAT,
fileProperties.ordinal(), fileProperties.generation());
+ }
+
+ static FileProperties fileProperties(Path path) {
+ Matcher matcher =
SEGMENT_FILE_NAME_PATTERN.matcher(path.getFileName().toString());
+
+ if (!matcher.matches()) {
+ throw new IllegalArgumentException(String.format("Invalid segment
file name format: %s.", path));
+ }
+
+ return new FileProperties(
+ Integer.parseInt(matcher.group("ordinal")),
+ Integer.parseInt(matcher.group("generation"))
+ );
+ }
+
+ FileProperties fileProperties() {
+ return fileProperties;
+ }
+
+ Path path() {
+ return path;
+ }
+
ByteBuffer buffer() {
return buffer.duplicate().order(BYTE_ORDER);
}
diff --git
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManager.java
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManager.java
index c84ab41e3ac..1829cc9a3e8 100644
---
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManager.java
+++
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManager.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.raft.storage.segstore;
import static java.lang.Math.toIntExact;
import static
org.apache.ignite.internal.raft.configuration.LogStorageConfigurationSchema.UNSPECIFIED_MAX_LOG_ENTRY_SIZE;
import static
org.apache.ignite.internal.raft.configuration.LogStorageConfigurationSchema.computeDefaultMaxLogEntrySizeBytes;
+import static
org.apache.ignite.internal.raft.storage.segstore.SegmentFile.fileName;
import static
org.apache.ignite.internal.raft.storage.segstore.SegmentInfo.MISSING_SEGMENT_FILE_OFFSET;
import static
org.apache.ignite.internal.raft.storage.segstore.SegmentPayload.RESET_RECORD_SIZE;
import static
org.apache.ignite.internal.raft.storage.segstore.SegmentPayload.TRUNCATE_PREFIX_RECORD_SIZE;
@@ -33,8 +34,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.apache.ignite.internal.close.ManuallyCloseable;
import org.apache.ignite.internal.failure.FailureProcessor;
@@ -101,10 +100,6 @@ class SegmentFileManager implements ManuallyCloseable {
static final int FORMAT_VERSION = 1;
- private static final String SEGMENT_FILE_NAME_FORMAT =
"segment-%010d-%010d.bin";
-
- private static final Pattern SEGMENT_FILE_NAME_PATTERN =
Pattern.compile("segment-(?<ordinal>\\d{10})-(?<generation>\\d{10})\\.bin");
-
/**
* Byte sequence that is written at the beginning of every segment file.
*/
@@ -207,14 +202,14 @@ class SegmentFileManager implements ManuallyCloseable {
lastSegmentFilePath = segmentFilePath;
} else {
// Create missing index files.
- int segmentFileOrdinal =
segmentFileOrdinal(segmentFilePath);
+ FileProperties segmentFileProperties =
SegmentFile.fileProperties(segmentFilePath);
- if (!indexFileManager.indexFileExists(segmentFileOrdinal))
{
+ if
(!indexFileManager.indexFileExists(segmentFileProperties)) {
LOG.info("Creating missing index file for segment file
{}.", segmentFilePath);
SegmentFileWithMemtable segmentFileWithMemtable =
recoverSegmentFile(segmentFilePath, payloadParser);
-
indexFileManager.recoverIndexFile(segmentFileWithMemtable.memtable().transitionToReadMode(),
segmentFileOrdinal);
+
indexFileManager.recoverIndexFile(segmentFileWithMemtable.memtable().transitionToReadMode(),
segmentFileProperties);
}
}
}
@@ -223,7 +218,7 @@ class SegmentFileManager implements ManuallyCloseable {
if (lastSegmentFilePath == null) {
currentSegmentFile.set(allocateNewSegmentFile(0));
} else {
- curSegmentFileOrdinal = segmentFileOrdinal(lastSegmentFilePath);
+ curSegmentFileOrdinal =
SegmentFile.fileProperties(lastSegmentFilePath).ordinal();
currentSegmentFile.set(recoverLatestSegmentFile(lastSegmentFilePath,
payloadParser));
}
@@ -250,7 +245,7 @@ class SegmentFileManager implements ManuallyCloseable {
}
private SegmentFileWithMemtable allocateNewSegmentFile(int fileOrdinal)
throws IOException {
- Path path = segmentFilesDir.resolve(segmentFileName(fileOrdinal, 0));
+ Path path = segmentFilesDir.resolve(fileName(new
FileProperties(fileOrdinal)));
SegmentFile segmentFile = SegmentFile.createNew(path, segmentFileSize,
isSync);
@@ -264,14 +259,8 @@ class SegmentFileManager implements ManuallyCloseable {
* "complete" segment files (i.e. those that have experienced a rollover)
this method is expected to be called on the most recent,
* possibly incomplete segment file.
*/
- private SegmentFileWithMemtable recoverLatestSegmentFile(
- Path segmentFilePath, SegmentPayloadParser payloadParser
- ) throws IOException {
- SegmentFile segmentFile = SegmentFile.openExisting(segmentFilePath,
isSync);
-
- WriteModeIndexMemTable memTable =
payloadParser.recoverMemtable(segmentFile, segmentFilePath, true);
-
- return new SegmentFileWithMemtable(segmentFile, memTable, false);
+ private SegmentFileWithMemtable recoverLatestSegmentFile(Path
segmentFilePath, SegmentPayloadParser payloadParser) throws IOException {
+ return recoverSegmentFile(segmentFilePath, payloadParser, true);
}
/**
@@ -281,20 +270,22 @@ class SegmentFileManager implements ManuallyCloseable {
* <p>This method skips CRC validation, because it is used to identify the
end of incomplete segment files (and, by definition, this can
* never happen during this method's invocation), not to validate storage
integrity.
*/
+ private SegmentFileWithMemtable recoverSegmentFile(Path segmentFilePath,
SegmentPayloadParser payloadParser) throws IOException {
+ return recoverSegmentFile(segmentFilePath, payloadParser, false);
+ }
+
private SegmentFileWithMemtable recoverSegmentFile(
- Path segmentFilePath, SegmentPayloadParser payloadParser
+ Path segmentFilePath,
+ SegmentPayloadParser payloadParser,
+ boolean validateCrc
) throws IOException {
SegmentFile segmentFile = SegmentFile.openExisting(segmentFilePath,
isSync);
- WriteModeIndexMemTable memTable =
payloadParser.recoverMemtable(segmentFile, segmentFilePath, false);
+ WriteModeIndexMemTable memTable =
payloadParser.recoverMemtable(segmentFile, validateCrc);
return new SegmentFileWithMemtable(segmentFile, memTable, false);
}
- private static String segmentFileName(int fileOrdinal, int generation) {
- return String.format(SEGMENT_FILE_NAME_FORMAT, fileOrdinal,
generation);
- }
-
private static SegmentFileWithMemtable
convertToReadOnly(SegmentFileWithMemtable segmentFile) {
return new SegmentFileWithMemtable(segmentFile.segmentFile(),
segmentFile.memtable(), true);
}
@@ -556,7 +547,7 @@ class SegmentFileManager implements ManuallyCloseable {
return EntrySearchResult.notFound();
}
- Path path =
segmentFilesDir.resolve(segmentFileName(segmentFilePointer.fileOrdinal(), 0));
+ Path path =
segmentFilesDir.resolve(fileName(segmentFilePointer.fileProperties()));
// TODO: Add a cache for recently accessed segment files, see
https://issues.apache.org/jira/browse/IGNITE-26622.
SegmentFile segmentFile = SegmentFile.openExisting(path, isSync);
@@ -566,18 +557,6 @@ class SegmentFileManager implements ManuallyCloseable {
return EntrySearchResult.success(buffer);
}
- private static int segmentFileOrdinal(Path segmentFile) {
- String fileName = segmentFile.getFileName().toString();
-
- Matcher matcher = SEGMENT_FILE_NAME_PATTERN.matcher(fileName);
-
- if (!matcher.matches()) {
- throw new IllegalArgumentException(String.format("Invalid segment
file name format: %s.", segmentFile));
- }
-
- return Integer.parseInt(matcher.group("ordinal"));
- }
-
private static int maxLogEntrySize(LogStorageView storageConfiguration) {
int valueFromConfig = storageConfiguration.maxLogEntrySizeBytes();
diff --git
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFilePointer.java
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFilePointer.java
index 57c967c47b1..739dee725aa 100644
---
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFilePointer.java
+++
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFilePointer.java
@@ -20,17 +20,17 @@ package org.apache.ignite.internal.raft.storage.segstore;
import org.apache.ignite.internal.tostring.S;
class SegmentFilePointer {
- private final int fileOrdinal;
+ private final FileProperties fileProperties;
private final int payloadOffset;
- SegmentFilePointer(int fileOrdinal, int payloadOffset) {
- this.fileOrdinal = fileOrdinal;
+ SegmentFilePointer(FileProperties fileProperties, int payloadOffset) {
+ this.fileProperties = fileProperties;
this.payloadOffset = payloadOffset;
}
- int fileOrdinal() {
- return fileOrdinal;
+ FileProperties fileProperties() {
+ return fileProperties;
}
int payloadOffset() {
@@ -44,12 +44,12 @@ class SegmentFilePointer {
}
SegmentFilePointer that = (SegmentFilePointer) o;
- return fileOrdinal == that.fileOrdinal && payloadOffset ==
that.payloadOffset;
+ return payloadOffset == that.payloadOffset &&
fileProperties.equals(that.fileProperties);
}
@Override
public int hashCode() {
- int result = fileOrdinal;
+ int result = fileProperties.hashCode();
result = 31 * result + payloadOffset;
return result;
}
diff --git
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentPayloadParser.java
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentPayloadParser.java
index 0a6499b980a..332336cc42d 100644
---
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentPayloadParser.java
+++
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentPayloadParser.java
@@ -38,10 +38,10 @@ class SegmentPayloadParser {
this.stripes = stripes;
}
- WriteModeIndexMemTable recoverMemtable(SegmentFile segmentFile, Path
segmentFilePath, boolean validateCrc) {
+ WriteModeIndexMemTable recoverMemtable(SegmentFile segmentFile, boolean
validateCrc) {
ByteBuffer buffer = segmentFile.buffer();
- validateSegmentFileHeader(buffer, segmentFilePath);
+ validateSegmentFileHeader(buffer, segmentFile.path());
var memtable = new IndexMemTable(stripes);
diff --git
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/GroupIndexMetaTest.java
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/GroupIndexMetaTest.java
index da01d0eb8c7..797e545d2a4 100644
---
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/GroupIndexMetaTest.java
+++
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/GroupIndexMetaTest.java
@@ -31,11 +31,11 @@ import org.junit.jupiter.api.Test;
class GroupIndexMetaTest extends BaseIgniteAbstractTest {
@Test
void testAddGet() {
- var initialMeta = new IndexFileMeta(1, 50, 0, 0);
+ var initialMeta = new IndexFileMeta(1, 50, 0, new FileProperties(0));
var groupMeta = new GroupIndexMeta(initialMeta);
- var additionalMeta = new IndexFileMeta(50, 100, 42, 1);
+ var additionalMeta = new IndexFileMeta(50, 100, 42, new
FileProperties(1));
groupMeta.addIndexMeta(additionalMeta);
@@ -52,11 +52,11 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
@Test
void testAddGetWithOverlap() {
- var initialMeta = new IndexFileMeta(1, 100, 0, 0);
+ var initialMeta = new IndexFileMeta(1, 100, 0, new FileProperties(0));
var groupMeta = new GroupIndexMeta(initialMeta);
- var additionalMeta = new IndexFileMeta(42, 100, 42, 1);
+ var additionalMeta = new IndexFileMeta(42, 100, 42, new
FileProperties(1));
groupMeta.addIndexMeta(additionalMeta);
@@ -75,7 +75,7 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
@Test
void testEmptyMetas() {
- var initialMeta = new IndexFileMeta(1, 1, 0, 0);
+ var initialMeta = new IndexFileMeta(1, 1, 0, new FileProperties(0));
var groupMeta = new GroupIndexMeta(initialMeta);
@@ -85,7 +85,7 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
assertThat(groupMeta.lastLogIndexExclusive(), is(1L));
- var additionalMeta = new IndexFileMeta(1, 2, 42, 1);
+ var additionalMeta = new IndexFileMeta(1, 2, 42, new
FileProperties(1));
groupMeta.addIndexMeta(additionalMeta);
@@ -104,7 +104,7 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
int logEntriesPerFile = 50;
- var initialMeta = new IndexFileMeta(0, logEntriesPerFile, 0,
startFileOrdinal);
+ var initialMeta = new IndexFileMeta(0, logEntriesPerFile, 0, new
FileProperties(startFileOrdinal));
var groupMeta = new GroupIndexMeta(initialMeta);
@@ -115,7 +115,8 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
long startLogIndex = relativeFileOrdinal * logEntriesPerFile;
long lastLogIndex = startLogIndex + logEntriesPerFile;
- groupMeta.addIndexMeta(new IndexFileMeta(startLogIndex,
lastLogIndex, 0, startFileOrdinal + relativeFileOrdinal));
+ groupMeta.addIndexMeta(
+ new IndexFileMeta(startLogIndex, lastLogIndex, 0, new
FileProperties(startFileOrdinal + relativeFileOrdinal)));
}
};
@@ -134,7 +135,8 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
int expectedEndLogIndex = expectedStartLogIndex +
logEntriesPerFile;
- var expectedMeta = new
IndexFileMeta(expectedStartLogIndex, expectedEndLogIndex, 0,
expectedFileOrdinal);
+ var expectedMeta = new
IndexFileMeta(expectedStartLogIndex, expectedEndLogIndex, 0,
+ new FileProperties(expectedFileOrdinal));
assertThat(indexFileMeta, is(expectedMeta));
}
@@ -150,7 +152,7 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
int logEntriesPerFile = 50;
- var initialMeta = new IndexFileMeta(0, logEntriesPerFile - 1, 0,
startFileOrdinal);
+ var initialMeta = new IndexFileMeta(0, logEntriesPerFile - 1, 0, new
FileProperties(startFileOrdinal));
var groupMeta = new GroupIndexMeta(initialMeta);
@@ -163,7 +165,8 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
long startLogIndex = relativeFileOrdinal * (logEntriesPerFile
- overlap);
long lastLogIndex = startLogIndex + logEntriesPerFile - 1;
- groupMeta.addIndexMeta(new IndexFileMeta(startLogIndex,
lastLogIndex, 0, startFileOrdinal + relativeFileOrdinal));
+ groupMeta.addIndexMeta(
+ new IndexFileMeta(startLogIndex, lastLogIndex, 0, new
FileProperties(startFileOrdinal + relativeFileOrdinal)));
}
};
@@ -192,7 +195,7 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
expectedFirstLogIndex,
expectedFirstLogIndex + logEntriesPerFile - 1,
0,
- expectedFileOrdinal
+ new FileProperties(expectedFileOrdinal)
);
if (expectedFirstLogIndex == 0) {
@@ -202,7 +205,7 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
expectedFirstLogIndex + overlap -
logEntriesPerFile,
expectedFirstLogIndex + overlap - 1,
0,
- expectedFileOrdinal - 1
+ new FileProperties(expectedFileOrdinal - 1)
);
// We can possibly be reading from two different metas
- from the newer one (that overlaps the older one) or
@@ -221,10 +224,10 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
@Test
void testTruncatePrefix() {
- var meta1 = new IndexFileMeta(1, 100, 0, 0);
- var meta2 = new IndexFileMeta(42, 100, 42, 1);
- var meta3 = new IndexFileMeta(100, 120, 66, 2);
- var meta4 = new IndexFileMeta(110, 200, 95, 3);
+ var meta1 = new IndexFileMeta(1, 100, 0, new FileProperties(0));
+ var meta2 = new IndexFileMeta(42, 100, 42, new FileProperties(1));
+ var meta3 = new IndexFileMeta(100, 120, 66, new FileProperties(2));
+ var meta4 = new IndexFileMeta(110, 200, 95, new FileProperties(3));
var groupMeta = new GroupIndexMeta(meta1);
@@ -246,7 +249,7 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
assertThat(groupMeta.indexMeta(42), is(nullValue()));
// Payload offset is shifted 4 bytes in order to skip the truncated
entry.
- var trimmedMeta = new IndexFileMeta(43, 100, 46, 1);
+ var trimmedMeta = new IndexFileMeta(43, 100, 46, new
FileProperties(1));
assertThat(groupMeta.indexMeta(43), is(trimmedMeta));
assertThat(groupMeta.indexMeta(100), is(meta3));
@@ -261,8 +264,8 @@ class GroupIndexMetaTest extends BaseIgniteAbstractTest {
@Test
void testTruncatePrefixRemovesAllEntriesWhenKeptAfterLast() {
- var meta1 = new IndexFileMeta(1, 10, 0, 0);
- var meta2 = new IndexFileMeta(10, 20, 100, 1);
+ var meta1 = new IndexFileMeta(1, 10, 0, new FileProperties(0));
+ var meta2 = new IndexFileMeta(10, 20, 100, new FileProperties(1));
var groupMeta = new GroupIndexMeta(meta1);
groupMeta.addIndexMeta(meta2);
diff --git
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileManagerTest.java
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileManagerTest.java
index 4846fdad008..a538602acf1 100644
---
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileManagerTest.java
+++
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileManagerTest.java
@@ -46,9 +46,9 @@ class IndexFileManagerTest extends IgniteAbstractTest {
void testIndexFileNaming() throws IOException {
var memtable = new IndexMemTable(STRIPES);
- Path path0 = indexFileManager.saveIndexMemtable(memtable);
- Path path1 = indexFileManager.saveIndexMemtable(memtable);
- Path path2 = indexFileManager.saveIndexMemtable(memtable);
+ Path path0 = indexFileManager.saveNewIndexMemtable(memtable);
+ Path path1 = indexFileManager.saveNewIndexMemtable(memtable);
+ Path path2 = indexFileManager.saveNewIndexMemtable(memtable);
assertThat(path0,
is(indexFileManager.indexFilesDir().resolve("index-0000000000-0000000000.bin")));
assertThat(path1,
is(indexFileManager.indexFilesDir().resolve("index-0000000001-0000000000.bin")));
@@ -75,7 +75,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
}
}
- Path indexFile = indexFileManager.saveIndexMemtable(memtable);
+ Path indexFile = indexFileManager.saveNewIndexMemtable(memtable);
DeserializedIndexFile deserializedIndexFile =
DeserializedIndexFile.fromFile(indexFile);
@@ -115,7 +115,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
}
}
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
}
for (int memtableIndex = 0; memtableIndex < numMemtables;
memtableIndex++) {
@@ -126,7 +126,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
SegmentFilePointer pointer =
indexFileManager.getSegmentFilePointer(groupId, logIndex);
assertThat(pointer, is(notNullValue()));
- assertThat(pointer.fileOrdinal(), is(memtableIndex));
+ assertThat(pointer.fileProperties().ordinal(),
is(memtableIndex));
assertThat(pointer.payloadOffset(),
is(segmentFileOffsets[logIndex]));
}
}
@@ -141,7 +141,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 0, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.getSegmentFilePointer(0, 0),
is(notNullValue()));
assertThat(indexFileManager.getSegmentFilePointer(0, 1),
is(nullValue()));
@@ -157,33 +157,33 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 0, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
memtable.appendSegmentFileOffset(1, 0, 2);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
memtable.appendSegmentFileOffset(0, 1, 3);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(
indexFileManager.getSegmentFilePointer(0, 0),
- is(new SegmentFilePointer(0, 1))
+ is(new SegmentFilePointer(new FileProperties(0), 1))
);
assertThat(
indexFileManager.getSegmentFilePointer(1, 0),
- is(new SegmentFilePointer(1, 2))
+ is(new SegmentFilePointer(new FileProperties(1), 2))
);
assertThat(
indexFileManager.getSegmentFilePointer(0, 1),
- is(new SegmentFilePointer(2, 3))
+ is(new SegmentFilePointer(new FileProperties(2), 3))
);
}
@@ -193,7 +193,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 1, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.firstLogIndexInclusive(0), is(1L));
assertThat(indexFileManager.lastLogIndexExclusive(0), is(2L));
@@ -205,7 +205,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(1, 2, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.firstLogIndexInclusive(0), is(1L));
assertThat(indexFileManager.lastLogIndexExclusive(0), is(2L));
@@ -222,7 +222,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 2, 1);
memtable.appendSegmentFileOffset(0, 3, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.firstLogIndexInclusive(0), is(1L));
assertThat(indexFileManager.lastLogIndexExclusive(0), is(4L));
@@ -231,7 +231,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.truncateSuffix(0, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.firstLogIndexInclusive(0), is(1L));
assertThat(indexFileManager.lastLogIndexExclusive(0), is(2L));
@@ -245,7 +245,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 2, 1);
memtable.appendSegmentFileOffset(0, 3, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.firstLogIndexInclusive(0), is(1L));
assertThat(indexFileManager.lastLogIndexExclusive(0), is(4L));
@@ -254,7 +254,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.truncatePrefix(0, 2);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.firstLogIndexInclusive(0), is(2L));
assertThat(indexFileManager.lastLogIndexExclusive(0), is(4L));
@@ -268,26 +268,26 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 2, 2);
memtable.appendSegmentFileOffset(0, 3, 3);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(0, 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(0), 2)));
memtable = new IndexMemTable(STRIPES);
memtable.truncateSuffix(0, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
- assertThat(indexFileManager.getSegmentFilePointer(0, 1), is(new
SegmentFilePointer(0, 1)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 1), is(new
SegmentFilePointer(new FileProperties(0), 1)));
assertThat(indexFileManager.getSegmentFilePointer(0, 2),
is(nullValue()));
memtable = new IndexMemTable(STRIPES);
memtable.appendSegmentFileOffset(0, 2, 2);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(2, 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(2), 2)));
}
@Test
@@ -296,13 +296,13 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 1, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
memtable.appendSegmentFileOffset(0, 2, 2);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
indexFileManager = new IndexFileManager(workDir);
@@ -312,19 +312,19 @@ class IndexFileManagerTest extends IgniteAbstractTest {
indexFileManager.start();
- assertThat(indexFileManager.getSegmentFilePointer(0, 1), is(new
SegmentFilePointer(0, 1)));
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(1, 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 1), is(new
SegmentFilePointer(new FileProperties(0), 1)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(1), 2)));
assertThat(indexFileManager.getSegmentFilePointer(0, 3),
is(nullValue()));
memtable = new IndexMemTable(STRIPES);
memtable.appendSegmentFileOffset(0, 3, 3);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
- assertThat(indexFileManager.getSegmentFilePointer(0, 1), is(new
SegmentFilePointer(0, 1)));
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(1, 2)));
- assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(2, 3)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 1), is(new
SegmentFilePointer(new FileProperties(0), 1)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(1), 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(new FileProperties(2), 3)));
}
@Test
@@ -335,20 +335,20 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 2, 2);
memtable.appendSegmentFileOffset(0, 3, 3);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
memtable.truncateSuffix(0, 2);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
indexFileManager = new IndexFileManager(workDir);
indexFileManager.start();
- assertThat(indexFileManager.getSegmentFilePointer(0, 1), is(new
SegmentFilePointer(0, 1)));
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(0, 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 1), is(new
SegmentFilePointer(new FileProperties(0), 1)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(0), 2)));
assertThat(indexFileManager.getSegmentFilePointer(0, 3),
is(nullValue()));
}
@@ -360,41 +360,41 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 2, 2);
memtable.appendSegmentFileOffset(0, 3, 3);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
memtable.truncatePrefix(0, 2);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
indexFileManager = new IndexFileManager(workDir);
indexFileManager.start();
assertThat(indexFileManager.getSegmentFilePointer(0, 1),
is(nullValue()));
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(0, 2)));
- assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(0, 3)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(0), 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(new FileProperties(0), 3)));
}
@Test
void testExists() throws IOException {
- assertThat(indexFileManager.indexFileExists(0), is(false));
- assertThat(indexFileManager.indexFileExists(1), is(false));
+ assertThat(indexFileManager.indexFileExists(new FileProperties(0)),
is(false));
+ assertThat(indexFileManager.indexFileExists(new FileProperties(1)),
is(false));
var memtable = new IndexMemTable(STRIPES);
memtable.appendSegmentFileOffset(0, 1, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
- assertThat(indexFileManager.indexFileExists(0), is(true));
- assertThat(indexFileManager.indexFileExists(1), is(false));
+ assertThat(indexFileManager.indexFileExists(new FileProperties(0)),
is(true));
+ assertThat(indexFileManager.indexFileExists(new FileProperties(1)),
is(false));
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
- assertThat(indexFileManager.indexFileExists(0), is(true));
- assertThat(indexFileManager.indexFileExists(1), is(true));
+ assertThat(indexFileManager.indexFileExists(new FileProperties(0)),
is(true));
+ assertThat(indexFileManager.indexFileExists(new FileProperties(1)),
is(true));
}
@Test
@@ -403,21 +403,21 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 1, 1);
- indexFileManager.recoverIndexFile(memtable, 5);
+ indexFileManager.recoverIndexFile(memtable, new FileProperties(5));
memtable = new IndexMemTable(STRIPES);
memtable.appendSegmentFileOffset(0, 2, 2);
- indexFileManager.recoverIndexFile(memtable, 6);
+ indexFileManager.recoverIndexFile(memtable, new FileProperties(6));
// Restart the manager to update in-memory meta.
indexFileManager = new IndexFileManager(workDir);
indexFileManager.start();
- assertThat(indexFileManager.getSegmentFilePointer(0, 1), is(new
SegmentFilePointer(5, 1)));
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(6, 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 1), is(new
SegmentFilePointer(new FileProperties(5), 1)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(6), 2)));
}
@Test
@@ -426,29 +426,29 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 1, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
memtable.appendSegmentFileOffset(0, 2, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
memtable.appendSegmentFileOffset(0, 3, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
memtable.truncatePrefix(0, 2);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.getSegmentFilePointer(0, 1),
is(nullValue()));
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(1, 1)));
- assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(2, 1)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(1), 1)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(new FileProperties(2), 1)));
}
@Test
@@ -460,7 +460,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 3, 3);
memtable.appendSegmentFileOffset(0, 4, 4);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
@@ -468,11 +468,11 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.truncateSuffix(0, 3);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.getSegmentFilePointer(0, 1),
is(nullValue()));
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(0, 2)));
- assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(0, 3)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(0), 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(new FileProperties(0), 3)));
assertThat(indexFileManager.getSegmentFilePointer(0, 4),
is(nullValue()));
// Restart the manager to check recovery.
@@ -481,8 +481,8 @@ class IndexFileManagerTest extends IgniteAbstractTest {
indexFileManager.start();
assertThat(indexFileManager.getSegmentFilePointer(0, 1),
is(nullValue()));
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(0, 2)));
- assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(0, 3)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(0), 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(new FileProperties(0), 3)));
assertThat(indexFileManager.getSegmentFilePointer(0, 4),
is(nullValue()));
}
@@ -495,7 +495,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 3, 3);
memtable.appendSegmentFileOffset(0, 4, 4);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
@@ -503,11 +503,11 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 3, 5);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.getSegmentFilePointer(0, 1),
is(nullValue()));
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(0, 2)));
- assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(1, 5)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(0), 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 3), is(new
SegmentFilePointer(new FileProperties(1), 5)));
assertThat(indexFileManager.getSegmentFilePointer(0, 4),
is(nullValue()));
}
@@ -520,16 +520,16 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 3, 3);
memtable.appendSegmentFileOffset(0, 4, 4);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
memtable = new IndexMemTable(STRIPES);
memtable.reset(0, 2);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.getSegmentFilePointer(0, 1),
is(nullValue()));
- assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(0, 2)));
+ assertThat(indexFileManager.getSegmentFilePointer(0, 2), is(new
SegmentFilePointer(new FileProperties(0), 2)));
assertThat(indexFileManager.getSegmentFilePointer(0, 3),
is(nullValue()));
assertThat(indexFileManager.getSegmentFilePointer(0, 4),
is(nullValue()));
}
@@ -542,7 +542,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.appendSegmentFileOffset(0, 2, 1);
memtable.appendSegmentFileOffset(0, 3, 1);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.firstLogIndexInclusive(0), is(1L));
assertThat(indexFileManager.lastLogIndexExclusive(0), is(4L));
@@ -551,7 +551,7 @@ class IndexFileManagerTest extends IgniteAbstractTest {
memtable.reset(0, 2);
- indexFileManager.saveIndexMemtable(memtable);
+ indexFileManager.saveNewIndexMemtable(memtable);
assertThat(indexFileManager.firstLogIndexInclusive(0), is(2L));
assertThat(indexFileManager.lastLogIndexExclusive(0), is(3L));
diff --git
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMetaArrayTest.java
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMetaArrayTest.java
index 23a4e61f6d0..7e619fad3c0 100644
---
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMetaArrayTest.java
+++
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileMetaArrayTest.java
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test;
class IndexFileMetaArrayTest extends BaseIgniteAbstractTest {
@Test
void testAddGet() {
- var initialMeta = new IndexFileMeta(1, 2, 0, 0);
+ var initialMeta = new IndexFileMeta(1, 2, 0, new FileProperties(0));
var array = new IndexFileMetaArray(initialMeta);
@@ -37,7 +37,7 @@ class IndexFileMetaArrayTest extends BaseIgniteAbstractTest {
assertThat(array.firstLogIndexInclusive(), is(1L));
assertThat(array.lastLogIndexExclusive(), is(2L));
- var meta2 = new IndexFileMeta(2, 3, 0, 1);
+ var meta2 = new IndexFileMeta(2, 3, 0, new FileProperties(1));
array = array.add(meta2);
@@ -49,10 +49,10 @@ class IndexFileMetaArrayTest extends BaseIgniteAbstractTest
{
for (int i = 0; i < INITIAL_CAPACITY; i++) {
long logIndex = meta2.firstLogIndexInclusive() + i + 1;
- array = array.add(new IndexFileMeta(logIndex, logIndex + 1, 0, i +
2));
+ array = array.add(new IndexFileMeta(logIndex, logIndex + 1, 0, new
FileProperties(i + 2)));
}
- var meta3 = new IndexFileMeta(INITIAL_CAPACITY + 3, INITIAL_CAPACITY +
4, 0, INITIAL_CAPACITY + 3);
+ var meta3 = new IndexFileMeta(INITIAL_CAPACITY + 3, INITIAL_CAPACITY +
4, 0, new FileProperties(INITIAL_CAPACITY + 3));
array = array.add(meta3);
@@ -64,9 +64,9 @@ class IndexFileMetaArrayTest extends BaseIgniteAbstractTest {
@Test
void testFindReturnsCorrectIndex() {
- var meta1 = new IndexFileMeta(1, 10, 100, 0);
- var meta2 = new IndexFileMeta(10, 20, 200, 1);
- var meta3 = new IndexFileMeta(20, 30, 300, 2);
+ var meta1 = new IndexFileMeta(1, 10, 100, new FileProperties(0));
+ var meta2 = new IndexFileMeta(10, 20, 200, new FileProperties(1));
+ var meta3 = new IndexFileMeta(20, 30, 300, new FileProperties(2));
IndexFileMetaArray array = new IndexFileMetaArray(meta1)
.add(meta2)
@@ -91,7 +91,7 @@ class IndexFileMetaArrayTest extends BaseIgniteAbstractTest {
@Test
void testFindReturnsNullForOutOfRange() {
- var meta = new IndexFileMeta(100, 200, 1000, 0);
+ var meta = new IndexFileMeta(100, 200, 1000, new FileProperties(0));
var array = new IndexFileMetaArray(meta);
assertThat(array.find(99), is(nullValue()));
@@ -100,9 +100,9 @@ class IndexFileMetaArrayTest extends BaseIgniteAbstractTest
{
@Test
void testFindWorksCorrectlyWithEmptyMetas() {
- var meta1 = new IndexFileMeta(1, 10, 100, 0);
- var meta2 = new IndexFileMeta(10, 10, 200, 1);
- var meta3 = new IndexFileMeta(10, 20, 200, 2);
+ var meta1 = new IndexFileMeta(1, 10, 100, new FileProperties(0));
+ var meta2 = new IndexFileMeta(10, 10, 200, new FileProperties(1));
+ var meta3 = new IndexFileMeta(10, 20, 200, new FileProperties(2));
IndexFileMetaArray array = new IndexFileMetaArray(meta1)
.add(meta2)
@@ -114,8 +114,8 @@ class IndexFileMetaArrayTest extends BaseIgniteAbstractTest
{
@Test
void testTruncateInsideMetaAdjustsPayloadOffset() {
- var meta1 = new IndexFileMeta(1, 10, 100, 0);
- var meta2 = new IndexFileMeta(10, 20, 200, 1);
+ var meta1 = new IndexFileMeta(1, 10, 100, new FileProperties(0));
+ var meta2 = new IndexFileMeta(10, 20, 200, new FileProperties(1));
IndexFileMetaArray array = new IndexFileMetaArray(meta1).add(meta2);
@@ -134,8 +134,8 @@ class IndexFileMetaArrayTest extends BaseIgniteAbstractTest
{
@Test
void testTruncateToMetaBoundarySkipsPreviousMeta() {
- var meta1 = new IndexFileMeta(1, 10, 100, 0);
- var meta2 = new IndexFileMeta(10, 20, 200, 1);
+ var meta1 = new IndexFileMeta(1, 10, 100, new FileProperties(0));
+ var meta2 = new IndexFileMeta(10, 20, 200, new FileProperties(1));
IndexFileMetaArray array = new IndexFileMetaArray(meta1).add(meta2);
diff --git
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogCheckpointerTest.java
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogCheckpointerTest.java
index c8d56c432ea..25c05ebac59 100644
---
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogCheckpointerTest.java
+++
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogCheckpointerTest.java
@@ -78,7 +78,7 @@ class RaftLogCheckpointerTest extends BaseIgniteAbstractTest {
checkpointer.onRollover(segmentFile, memTable);
verify(segmentFile, timeout(500)).sync();
- verify(indexFileManager, timeout(500)).saveIndexMemtable(memTable);
+ verify(indexFileManager, timeout(500)).saveNewIndexMemtable(memTable);
}
@Test
diff --git
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManagerTest.java
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManagerTest.java
index f8e35fc3992..9bf3099fb7e 100644
---
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManagerTest.java
+++
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManagerTest.java
@@ -491,20 +491,14 @@ class SegmentFileManagerTest extends IgniteAbstractTest {
when(mockMemTable.iterator()).thenThrow(new RuntimeException("Test
exception"));
- // Create two tmp index files: one for the complete segment file and
one the incomplete segment file.
+ // Create a tmp file for the incomplete segment file.
try {
- fileManager.indexFileManager().recoverIndexFile(mockMemTable, 0);
+ fileManager.indexFileManager().recoverIndexFile(mockMemTable, new
FileProperties(1));
} catch (RuntimeException ignored) {
// Ignore.
}
- try {
- fileManager.indexFileManager().recoverIndexFile(mockMemTable, 1);
- } catch (RuntimeException ignored) {
- // Ignore.
- }
-
- assertThat(tmpIndexFiles(), hasSize(2));
+ assertThat(tmpIndexFiles(), hasSize(1));
fileManager.close();
diff --git
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileTest.java
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileTest.java
index 1b9b5ad8007..bd053f0468d 100644
---
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileTest.java
+++
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileTest.java
@@ -68,7 +68,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
*/
@ExtendWith(ExecutorServiceExtension.class)
class SegmentFileTest extends IgniteAbstractTest {
- private static final String FILE_NAME = "test.bin";
+ private static final String FILE_NAME = SegmentFile.fileName(new
FileProperties(0));
private Path path;
diff --git
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SyncSegmentFileTest.java
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SyncSegmentFileTest.java
index ebd02ae7146..70868dd04ce 100644
---
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SyncSegmentFileTest.java
+++
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SyncSegmentFileTest.java
@@ -39,7 +39,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(ExecutorServiceExtension.class)
class SyncSegmentFileTest extends IgniteAbstractTest {
- private static final String FILE_NAME = "test.bin";
+ private static final String FILE_NAME = SegmentFile.fileName(new
FileProperties(0));
private static final int size = 1024;