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 234a393261a IGNITE-28392 Add LogStorageManager for SegstoreLogStorage 
(#7937)
234a393261a is described below

commit 234a393261a753d29c0d43e1d33f58bc5c0b354e
Author: Phillippko <[email protected]>
AuthorDate: Wed Apr 8 16:07:13 2026 +0400

    IGNITE-28392 Add LogStorageManager for SegstoreLogStorage (#7937)
---
 .../storage/segstore/RaftLogGarbageCollector.java  |   2 +-
 .../raft/storage/segstore/SegmentFileManager.java  |  12 +-
 .../storage/segstore/SegmentLogStorageManager.java | 118 +++++++++++++++
 .../segstore/RaftLogGarbageCollectorTest.java      |   6 +-
 .../storage/segstore/RaftLogGcSoftLimitTest.java   |   2 +-
 .../segstore/SegmentFileManagerGetEntryTest.java   |   2 +-
 .../storage/segstore/SegmentFileManagerTest.java   |   2 +-
 .../SegstoreLogStorageConcurrencyTest.java         |   2 +-
 .../storage/segstore/SegstoreLogStorageTest.java   |   2 +-
 .../jraft/storage/logit/HybridLogStorageTest.java  | 166 +++++++++++++--------
 10 files changed, 240 insertions(+), 74 deletions(-)

diff --git 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGarbageCollector.java
 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGarbageCollector.java
index 9bea071197b..89cf8bdb48b 100644
--- 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGarbageCollector.java
+++ 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGarbageCollector.java
@@ -207,7 +207,7 @@ class RaftLogGarbageCollector {
         }
     }
 
-    @VisibleForTesting
+    /** Returns current size of all log storage files in bytes. */
     long logSizeBytes() {
         return logSizeBytes.get();
     }
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 83ec684d76a..6c9f952acb7 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
@@ -42,7 +42,6 @@ import org.apache.ignite.internal.logger.IgniteLogger;
 import org.apache.ignite.internal.logger.Loggers;
 import org.apache.ignite.internal.raft.configuration.LogStorageConfiguration;
 import org.apache.ignite.internal.raft.configuration.LogStorageView;
-import org.apache.ignite.internal.raft.configuration.RaftConfiguration;
 import 
org.apache.ignite.internal.raft.storage.segstore.EntrySearchResult.SearchOutcome;
 import 
org.apache.ignite.internal.raft.storage.segstore.SegmentFile.WriteBuffer;
 import org.apache.ignite.raft.jraft.entity.LogEntry;
@@ -162,7 +161,7 @@ class SegmentFileManager implements ManuallyCloseable {
             Path baseDir,
             int stripes,
             FailureProcessor failureProcessor,
-            RaftConfiguration raftConfiguration,
+            boolean isSync,
             LogStorageConfiguration storageConfiguration
     ) throws IOException {
         this.storageName = storageName;
@@ -171,7 +170,7 @@ class SegmentFileManager implements ManuallyCloseable {
 
         this.segmentFilesDir = storageDir.resolve("segments");
         this.stripes = stripes;
-        this.isSync = raftConfiguration.fsync().value();
+        this.isSync = isSync;
 
         Files.createDirectories(segmentFilesDir);
 
@@ -483,12 +482,19 @@ class SegmentFileManager implements ManuallyCloseable {
         return indexFileManager.lastLogIndexExclusive(groupId);
     }
 
+    /** Returns current size of all log storage files in bytes. */
+    long logSizeBytes() {
+        return garbageCollector.logSizeBytes();
+    }
+
     /**
      * Returns the current segment file possibly waiting for an ongoing 
rollover to complete.
      */
     private SegmentFileWithMemtable currentSegmentFile() {
         SegmentFileWithMemtable segmentFile = currentSegmentFile.get();
 
+        assert segmentFile != null : "Segment file manager is not started";
+
         if (!segmentFile.readOnly()) {
             return segmentFile;
         }
diff --git 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentLogStorageManager.java
 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentLogStorageManager.java
new file mode 100644
index 00000000000..981d29c372a
--- /dev/null
+++ 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentLogStorageManager.java
@@ -0,0 +1,118 @@
+/*
+ * 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.raft.storage.segstore;
+
+import static java.util.concurrent.CompletableFuture.failedFuture;
+import static 
org.apache.ignite.internal.util.CompletableFutures.nullCompletedFuture;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.regex.Pattern;
+import org.apache.ignite.internal.failure.FailureProcessor;
+import org.apache.ignite.internal.manager.ComponentContext;
+import org.apache.ignite.internal.raft.configuration.LogStorageConfiguration;
+import org.apache.ignite.internal.raft.storage.LogStorageManager;
+import org.apache.ignite.internal.raft.storage.impl.LogStorageException;
+import org.apache.ignite.raft.jraft.option.RaftOptions;
+import org.apache.ignite.raft.jraft.storage.LogStorage;
+
+/**
+ * Log storage manager for {@link SegstoreLogStorage} instances.
+ */
+public class SegmentLogStorageManager implements LogStorageManager {
+    private static final Pattern PARTITION_GROUP_ID_PATTERN = 
Pattern.compile("_part_");
+
+    private final SegmentFileManager fileManager;
+
+    public SegmentLogStorageManager(
+            String nodeName,
+            Path logStoragePath,
+            int stripes,
+            FailureProcessor failureProcessor,
+            boolean fsync,
+            LogStorageConfiguration storageConfiguration
+    ) throws IOException {
+        this.fileManager = new SegmentFileManager(nodeName, logStoragePath, 
stripes, failureProcessor, fsync, storageConfiguration);
+    }
+
+    @Override
+    public LogStorage createLogStorage(String groupId, RaftOptions 
raftOptions) {
+        return new SegstoreLogStorage(convertGroupId(groupId), fileManager);
+    }
+
+    @Override
+    public void destroyLogStorage(String groupId) {
+        try {
+            fileManager.reset(convertGroupId(groupId), 1);
+        } catch (IOException e) {
+            throw new LogStorageException("Failed to destroy log storage for 
group " + groupId, e);
+        }
+    }
+
+    @Override
+    public Set<String> raftNodeStorageIdsOnDisk() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public long totalBytesOnDisk() {
+        return fileManager.logSizeBytes();
+    }
+
+    @Override
+    public CompletableFuture<Void> startAsync(ComponentContext 
componentContext) {
+        try {
+            fileManager.start();
+
+            return nullCompletedFuture();
+        } catch (IOException e) {
+            return failedFuture(new LogStorageException("Couldn't start 
SegmentLogStorageManager", e));
+        }
+    }
+
+    @Override
+    public CompletableFuture<Void> stopAsync(ComponentContext 
componentContext) {
+        try {
+            fileManager.close();
+
+            return nullCompletedFuture();
+        } catch (Exception e) {
+            return failedFuture(new LogStorageException("Couldn't stop 
SegmentLogStorageManager", e));
+        }
+    }
+
+    private static long convertGroupId(String groupId) {
+        if ("metastorage_group".equals(groupId)) {
+            return 1;
+        }
+
+        if ("cmg_group".equals(groupId)) {
+            return 2;
+        }
+
+        String[] partitionGroupIdArray = 
PARTITION_GROUP_ID_PATTERN.split(groupId);
+
+        if (partitionGroupIdArray.length == 2) {
+            return Long.parseLong(partitionGroupIdArray[0]) << 32 | 
Long.parseLong(partitionGroupIdArray[1]);
+        } else {
+            throw new IllegalArgumentException("Invalid groupId: " + groupId);
+        }
+    }
+}
diff --git 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGarbageCollectorTest.java
 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGarbageCollectorTest.java
index 82fc9182380..2ce340b12f2 100644
--- 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGarbageCollectorTest.java
+++ 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGarbageCollectorTest.java
@@ -94,7 +94,7 @@ class RaftLogGarbageCollectorTest extends IgniteAbstractTest {
                 workDir,
                 STRIPES,
                 new NoOpFailureManager(),
-                raftConfiguration,
+                raftConfiguration.fsync().value(),
                 storageConfiguration
         );
 
@@ -417,7 +417,7 @@ class RaftLogGarbageCollectorTest extends 
IgniteAbstractTest {
                 workDir,
                 STRIPES,
                 new NoOpFailureManager(),
-                raftConfiguration,
+                raftConfiguration.fsync().value(),
                 storageConfiguration
         );
 
@@ -743,7 +743,7 @@ class RaftLogGarbageCollectorTest extends 
IgniteAbstractTest {
                 workDir,
                 STRIPES,
                 new NoOpFailureManager(),
-                raftConfiguration,
+                raftConfiguration.fsync().value(),
                 storageConfiguration
         );
 
diff --git 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGcSoftLimitTest.java
 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGcSoftLimitTest.java
index ae4ee28888e..0101d25a18e 100644
--- 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGcSoftLimitTest.java
+++ 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGcSoftLimitTest.java
@@ -91,7 +91,7 @@ class RaftLogGcSoftLimitTest extends IgniteAbstractTest {
                 workDir,
                 STRIPES,
                 new NoOpFailureManager(),
-                raftConfiguration,
+                raftConfiguration.fsync().value(),
                 storageConfiguration
         );
 
diff --git 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManagerGetEntryTest.java
 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManagerGetEntryTest.java
index 3d98d751717..0dcebe3e1d8 100644
--- 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManagerGetEntryTest.java
+++ 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManagerGetEntryTest.java
@@ -88,7 +88,7 @@ class SegmentFileManagerGetEntryTest extends 
IgniteAbstractTest {
                 workDir,
                 STRIPES,
                 new NoOpFailureManager(),
-                raftConfiguration,
+                raftConfiguration.fsync().value(),
                 storageConfiguration
         );
 
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 f3a6c7271c3..8d783a8a098 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
@@ -120,7 +120,7 @@ class SegmentFileManagerTest extends IgniteAbstractTest {
                 workDir,
                 STRIPES,
                 failureManager,
-                raftConfiguration,
+                raftConfiguration.fsync().value(),
                 storageConfiguration
         );
     }
diff --git 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegstoreLogStorageConcurrencyTest.java
 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegstoreLogStorageConcurrencyTest.java
index e9eead54f8c..c555b516eed 100644
--- 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegstoreLogStorageConcurrencyTest.java
+++ 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegstoreLogStorageConcurrencyTest.java
@@ -62,7 +62,7 @@ class SegstoreLogStorageConcurrencyTest extends 
IgniteAbstractTest {
                 workDir,
                 1,
                 new NoOpFailureManager(),
-                raftConfiguration,
+                raftConfiguration.fsync().value(),
                 storageConfiguration
         );
 
diff --git 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegstoreLogStorageTest.java
 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegstoreLogStorageTest.java
index 29f6dec143f..58c36175517 100644
--- 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegstoreLogStorageTest.java
+++ 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/storage/segstore/SegstoreLogStorageTest.java
@@ -65,7 +65,7 @@ class SegstoreLogStorageTest extends BaseLogStorageTest {
                     path,
                     1,
                     new NoOpFailureManager(),
-                    raftConfiguration,
+                    raftConfiguration.fsync().value(),
                     storageConfiguration
             );
 
diff --git 
a/modules/raft/src/test/java/org/apache/ignite/raft/jraft/storage/logit/HybridLogStorageTest.java
 
b/modules/raft/src/test/java/org/apache/ignite/raft/jraft/storage/logit/HybridLogStorageTest.java
index 7be47dc1532..d563563b900 100644
--- 
a/modules/raft/src/test/java/org/apache/ignite/raft/jraft/storage/logit/HybridLogStorageTest.java
+++ 
b/modules/raft/src/test/java/org/apache/ignite/raft/jraft/storage/logit/HybridLogStorageTest.java
@@ -17,16 +17,25 @@
 
 package org.apache.ignite.raft.jraft.storage.logit;
 
+import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import 
org.apache.ignite.internal.configuration.testframework.ConfigurationExtension;
+import 
org.apache.ignite.internal.configuration.testframework.InjectConfiguration;
+import org.apache.ignite.internal.failure.NoOpFailureManager;
+import org.apache.ignite.internal.manager.ComponentContext;
+import org.apache.ignite.internal.raft.configuration.LogStorageConfiguration;
 import org.apache.ignite.internal.raft.storage.LogStorageManager;
-import org.apache.ignite.internal.raft.storage.impl.LocalLogStorageManager;
-import org.apache.ignite.internal.raft.storage.logit.LogitLogStorageManager;
+import org.apache.ignite.internal.raft.storage.impl.DefaultLogStorageManager;
+import 
org.apache.ignite.internal.raft.storage.segstore.SegmentLogStorageManager;
 import org.apache.ignite.raft.jraft.JRaftServiceFactory;
 import org.apache.ignite.raft.jraft.conf.ConfigurationManager;
 import org.apache.ignite.raft.jraft.core.HybridLogJRaftServiceFactory;
@@ -35,53 +44,114 @@ import 
org.apache.ignite.raft.jraft.option.LogStorageOptions;
 import org.apache.ignite.raft.jraft.option.RaftOptions;
 import org.apache.ignite.raft.jraft.storage.BaseStorageTest;
 import org.apache.ignite.raft.jraft.storage.LogStorage;
-import org.apache.ignite.raft.jraft.storage.impl.LocalLogStorage;
 import org.apache.ignite.raft.jraft.storage.logit.option.StoreOptions;
 import org.apache.ignite.raft.jraft.storage.logit.storage.HybridLogStorage;
 import org.apache.ignite.raft.jraft.test.TestUtils;
+import org.jetbrains.annotations.Nullable;
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 
+@ExtendWith(ConfigurationExtension.class)
 class HybridLogStorageTest extends BaseStorageTest {
     private static final String STORAGE_RELATIVE_PATH = "log";
 
     private static final String NEW_STORAGE_RELATIVE_PATH = "new";
 
+    private static final String GROUP_ID = "1_part_1";
+
+    private @Nullable LogStorageManager oldStorageFactory;
+
+    private LogStorageManager newStorageFactory;
+
+    @AfterEach
+    public void tearDown() throws Exception {
+        if (oldStorageFactory != null) {
+            oldStorageFactory.destroyLogStorage(GROUP_ID);
+            oldStorageFactory.stopAsync();
+        }
+
+        if (newStorageFactory != null) {
+            newStorageFactory.destroyLogStorage(GROUP_ID);
+            newStorageFactory.stopAsync();
+        }
+    }
+
     @Test
     public void testTransferLogStorage() {
+        Path storagePath = getStoragePath();
+
+        oldStorageFactory = new 
DefaultLogStorageManager(storagePath.resolve("old"));
+        newStorageFactory = new DefaultLogStorageManager(storagePath);
+
+        testHybridStorage();
+    }
+
+    @Test
+    public void testHybridStorageWithoutOldStorage() {
+        Path storagePath = 
path.resolve(STORAGE_RELATIVE_PATH).resolve(NEW_STORAGE_RELATIVE_PATH);
+
+        oldStorageFactory = null;
+        newStorageFactory = new DefaultLogStorageManager(storagePath);
+
+        testHybridStorage();
+    }
+
+    @Test
+    public void testHybridStorageWithSegStore(@InjectConfiguration 
LogStorageConfiguration logStorageConfiguration) throws IOException {
+        Path storagePath = getStoragePath();
+
+        newStorageFactory = new SegmentLogStorageManager(
+                "test",
+                storagePath,
+                1,
+                new NoOpFailureManager(),
+                false,
+                logStorageConfiguration
+        );
+
+        oldStorageFactory = new DefaultLogStorageManager(storagePath);
+
+        testHybridStorage();
+    }
+
+    private void testHybridStorage() {
         RaftOptions raftOptions = new RaftOptions();
+        raftOptions.setStartupOldStorage(oldStorageFactory != null);
 
-        raftOptions.setStartupOldStorage(true);
+        assertThat(newStorageFactory.startAsync(new ComponentContext()), 
willCompleteSuccessfully());
 
-        LogStorage oldStorage = new LocalLogStorage(raftOptions);
+        long expectedThresholdIndex;
 
-        LogStorageManager oldStorageFactory = new LocalLogStorageManager() {
-            @Override
-            public LogStorage createLogStorage(String uri, RaftOptions 
raftOptions) {
-                return oldStorage;
-            }
-        };
+        int valueCount = 10;
 
-        assertTrue(oldStorage.init(logStorageOptions()));
+        if (oldStorageFactory != null) {
+            assertThat(oldStorageFactory.startAsync(new ComponentContext()), 
willCompleteSuccessfully());
 
-        long valueCount = 10;
+            LogStorage oldStorage = 
oldStorageFactory.createLogStorage(GROUP_ID, new RaftOptions());
 
-        for (int i = 1; i <= valueCount; i++) {
-            oldStorage.appendEntry(TestUtils.mockEntry(i, 1));
-        }
+            assertTrue(oldStorage.init(logStorageOptions()));
 
-        oldStorage.shutdown();
+            for (int i = 1; i <= valueCount; i++) {
+                oldStorage.appendEntry(TestUtils.mockEntry(i, 1));
+            }
+
+            expectedThresholdIndex = oldStorage.getLastLogIndex() + 1;
+
+            oldStorage.shutdown();
+        } else {
+            expectedThresholdIndex = 0;
+        }
 
-        HybridLogStorage hybridLogStorage = 
createHybridLogStorage(raftOptions, oldStorageFactory);
+        HybridLogStorage hybridLogStorage = 
createHybridLogStorage(raftOptions, oldStorageFactory, newStorageFactory, 
getStoragePath());
 
         assertTrue(hybridLogStorage.init(logStorageOptions()));
 
-        assertTrue(hybridLogStorage.isOldStorageExist());
+        assertThat(hybridLogStorage.isOldStorageExist(), is(oldStorageFactory 
!= null));
 
         // Checkpoint saved to disk when storage is started.
         assertTrue(Files.exists(statusCheckpointPath()));
 
-        long expectedThresholdIndex = oldStorage.getLastLogIndex() + 1;
-
         assertEquals(expectedThresholdIndex, 
hybridLogStorage.getThresholdIndex());
 
         for (int i = 0; i < valueCount; i++) {
@@ -96,6 +166,9 @@ class HybridLogStorageTest extends BaseStorageTest {
 
         hybridLogStorage.shutdown();
 
+        // Storages don't support restarting after shutdown, so we need to 
create new one.
+        hybridLogStorage = createHybridLogStorage(raftOptions, 
oldStorageFactory, newStorageFactory, getStoragePath());
+
         assertTrue(hybridLogStorage.init(logStorageOptions()));
         assertFalse(hybridLogStorage.isOldStorageExist());
         assertEquals(0, hybridLogStorage.getThresholdIndex());
@@ -109,50 +182,19 @@ class HybridLogStorageTest extends BaseStorageTest {
         }
     }
 
-    @Test
-    public void testHybridStorageWithoutOldStorage() {
-        RaftOptions raftOptions = new RaftOptions();
-
-        raftOptions.setStartupOldStorage(false);
-
-        HybridLogStorage hybridLogStorage = 
createHybridLogStorage(raftOptions, null);
-
-        assertTrue(hybridLogStorage.init(logStorageOptions()));
-
-        assertFalse(hybridLogStorage.isOldStorageExist());
-        assertEquals(0, hybridLogStorage.getThresholdIndex());
-
-        // Checkpoint saved to disk when storage is started.
-        assertTrue(Files.exists(statusCheckpointPath()));
-
-        long valueCount = 10;
-
-        for (int i = 1; i <= valueCount; i++) {
-            hybridLogStorage.appendEntry(TestUtils.mockEntry(i, 1));
-        }
-
-        assertEquals(1, hybridLogStorage.getFirstLogIndex());
-        assertEquals(valueCount, hybridLogStorage.getLastLogIndex());
-
-        hybridLogStorage.shutdown();
-
-        hybridLogStorage.init(logStorageOptions());
-        assertFalse(hybridLogStorage.isOldStorageExist());
-        assertEquals(0, hybridLogStorage.getThresholdIndex());
-        assertEquals(1, hybridLogStorage.getFirstLogIndex());
-        assertEquals(valueCount, hybridLogStorage.getLastLogIndex());
+    private static HybridLogStorage createHybridLogStorage(
+            RaftOptions raftOptions,
+            @Nullable LogStorageManager oldStorageFactory,
+            LogStorageManager newStorageFactory,
+            Path storagePath
+    ) {
+        JRaftServiceFactory factory = new 
HybridLogJRaftServiceFactory(oldStorageFactory, newStorageFactory, storagePath);
 
-        hybridLogStorage.shutdown();
+        return (HybridLogStorage) factory.createLogStorage(GROUP_ID, 
raftOptions);
     }
 
-    private HybridLogStorage createHybridLogStorage(RaftOptions raftOptions, 
LogStorageManager oldStorageFactory) {
-        Path storagePath = 
path.resolve(STORAGE_RELATIVE_PATH).resolve(NEW_STORAGE_RELATIVE_PATH);
-
-        LogStorageManager newStorageFactory = new 
LogitLogStorageManager("test", storeOptions(), storagePath);
-
-        JRaftServiceFactory factory = new 
HybridLogJRaftServiceFactory(oldStorageFactory, newStorageFactory, storagePath);
-
-        return (HybridLogStorage) factory.createLogStorage("test-group-id", 
raftOptions);
+    private Path getStoragePath() {
+        return 
path.resolve(STORAGE_RELATIVE_PATH).resolve(NEW_STORAGE_RELATIVE_PATH);
     }
 
     private Path statusCheckpointPath() {

Reply via email to