ivanzlenko commented on code in PR #4530:
URL: https://github.com/apache/ignite-3/pull/4530#discussion_r1799676463


##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/raft/MetaStorageSnapshotStorageFactory.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.metastorage.impl.raft;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.internal.metastorage.server.KeyValueStorage;
+import org.apache.ignite.internal.raft.IndexWithTerm;
+import org.apache.ignite.internal.raft.RaftGroupConfiguration;
+import org.apache.ignite.internal.raft.storage.SnapshotStorageFactory;
+import org.apache.ignite.internal.util.ByteUtils;
+import org.apache.ignite.raft.jraft.RaftMessagesFactory;
+import org.apache.ignite.raft.jraft.entity.RaftOutter;
+import org.apache.ignite.raft.jraft.entity.RaftOutter.SnapshotMeta;
+import org.apache.ignite.raft.jraft.option.RaftOptions;
+import org.apache.ignite.raft.jraft.storage.SnapshotStorage;
+import org.apache.ignite.raft.jraft.storage.snapshot.SnapshotReader;
+import 
org.apache.ignite.raft.jraft.storage.snapshot.local.LocalSnapshotStorage;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot storage factory implementation for Meta Storage.
+ */
+public class MetaStorageSnapshotStorageFactory implements 
SnapshotStorageFactory {
+    private final KeyValueStorage storage;
+
+    /** Snapshot meta, constructed from the storage data and raft group 
configuration at startup. {@code null} if the storage is empty. */
+    private final @Nullable RaftOutter.SnapshotMeta startupSnapshotMeta;
+
+    /**
+     * Constructor.

Review Comment:
   ```suggestion
        * Constructor.
        * We will try to read a snapshot meta during initialization of the 
factory.  
   ```



##########
modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/SimpleInMemoryCompactionKeyValueStorageTest.java:
##########
@@ -23,4 +23,9 @@ public class SimpleInMemoryCompactionKeyValueStorageTest 
extends AbstractCompact
     public KeyValueStorage createStorage() {
         return new SimpleInMemoryKeyValueStorage("test");
     }
+
+    @Override
+    public void testSaveCompactionRevisionAndRestart() {

Review Comment:
   The same with access modifier for this method. 



##########
modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/rebalance/DistributionZoneRebalanceEngineTest.java:
##########
@@ -426,7 +427,7 @@ void replicasTriggersAssignmentsChangingOnNonDefaultZones() 
throws Exception {
 
         keyValueStorage.put(
                 stablePartAssignmentsKey(new 
TablePartitionId(getTableId(TABLE_NAME), 0)).bytes(), assignmentsBytes,
-                clock.now()
+                new KeyValueUpdateContext(0, 0, clock.now())

Review Comment:
   Isn't this is what we doing msContext() method? Can we just you that method 
to create an instance in such places? 



##########
modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/AbstractCompactionKeyValueStorageTest.java:
##########
@@ -225,12 +225,12 @@ void 
testSaveCompactionRevisionDoesNotChangeRevisionInMemory() {
     }
 
     @Test
-    void testSaveCompactionRevisionAndRestart() throws Exception {
+    public void testSaveCompactionRevisionAndRestart() throws Exception {

Review Comment:
   Why we need to make this method public? 



##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/raft/MetaStorageListener.java:
##########
@@ -207,7 +209,14 @@ public boolean onBeforeApply(Command command) {
 
     @Override
     public void onConfigurationCommitted(CommittedConfiguration config) {
-        RaftGroupListener.super.onConfigurationCommitted(config);
+        RaftGroupConfiguration configuration = new RaftGroupConfiguration(

Review Comment:
   Can we have a method RaftGroupConfiguration.fromCommitedConfiguration ?



##########
modules/metastorage/src/testFixtures/java/org/apache/ignite/internal/metastorage/server/AbstractKeyValueStorageTest.java:
##########
@@ -42,6 +43,11 @@ public void tearDown() throws Exception {
         storage.close();
     }
 
+    /** Creates a Meta Storage context based on a timestamp. Index and term 
will be {@code 0}. */
+    protected static KeyValueUpdateContext msContext(HybridTimestamp 
timestamp) {
+        return new KeyValueUpdateContext(0, 0, timestamp);

Review Comment:
   We are using such expression in a lot of places - can we make this method 
public and re-use whenever is possible? 



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to