sashapolo commented on code in PR #6577:
URL: https://github.com/apache/ignite-3/pull/6577#discussion_r2341720032


##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IgniteLogStorage.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * 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 org.apache.ignite.lang.ErrorGroups.Common.INTERNAL_ERR;
+
+import java.nio.ByteBuffer;
+import java.util.List;
+import org.apache.ignite.internal.lang.IgniteInternalException;
+import 
org.apache.ignite.internal.raft.storage.segstore.SegmentFile.WriteBuffer;
+import org.apache.ignite.internal.util.FastCrc;
+import org.apache.ignite.raft.jraft.entity.LogEntry;
+import org.apache.ignite.raft.jraft.entity.codec.LogEntryEncoder;
+import org.apache.ignite.raft.jraft.option.LogStorageOptions;
+import org.apache.ignite.raft.jraft.storage.LogStorage;
+
+/**
+ * Ignite's {@link LogStorage} implementation.
+ *
+ * <p>Every storage instance is associated with a single Raft group, but 
multiple storage instances can share the same
+ * {@link SegmentFileManager} instance meaning that they can share the same 
segment files.
+ *
+ * <p>Every appended entry is converted into its serialized form (a.k.a. 
"payload"), defined by a {@link LogEntryEncoder},
+ * and stored in a segment file.
+ *
+ * <p>Binary representation of each entry is as follows:
+ * <pre>
+ * 
+---------------+---------+--------------------------+---------+----------------+
+ * | Raft Group ID (8 bytes) | Payload Length (4 bytes) | Payload | Hash (4 
bytes) |
+ * 
+---------------+---------+--------------------------+---------+----------------+
+ * </pre>
+ */
+class IgniteLogStorage implements LogStorage {
+    static final int GROUP_ID_SIZE_BYTES = Long.BYTES;
+
+    static final int LENGTH_SIZE_BYTES = Integer.BYTES;
+
+    static final int HASH_SIZE = Integer.BYTES;
+
+    private final long groupId;
+
+    private final SegmentFileManager segmentFileManager;
+
+    private volatile LogEntryEncoder logEntryEncoder;

Review Comment:
   Because it is initialized in the `init` method and I have no idea what are 
the visibility guarantees between it and `appendEntry`, for example (this is 
JRaft code, not ours).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to