Use correct JournalSegmentWriter for initial indexing
[controller.git] / atomix-storage / src / main / java / io / atomix / storage / journal / JournalSegment.java
index ec685fe5c970714cdf3bacae06201da6847e58b0..0058186e2f2a13fae13a08f4425ce6cc0201586f 100644 (file)
@@ -64,7 +64,10 @@ final class JournalSegment<E> implements AutoCloseable {
     } catch (IOException e) {
       throw new StorageException(e);
     }
-    writer = new FileChannelJournalSegmentWriter<>(channel, this, maxEntrySize, index, namespace);
+    writer = switch (storageLevel) {
+        case DISK -> new FileChannelJournalSegmentWriter<>(channel, this, maxEntrySize, index, namespace);
+        case MAPPED -> new MappedJournalSegmentWriter<>(channel, this, maxEntrySize, index, namespace).toFileChannel();
+    };
   }
 
   /**