rpuch commented on code in PR #3815:
URL: https://github.com/apache/ignite-3/pull/3815#discussion_r1623845218


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/io/PartitionMetaIo.java:
##########
@@ -19,213 +19,36 @@
 
 import static org.apache.ignite.internal.pagememory.PageIdAllocator.FLAG_AUX;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.getInt;
-import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.putInt;
-import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
 
-import org.apache.ignite.internal.hlc.HybridTimestamp;
 import org.apache.ignite.internal.lang.IgniteStringBuilder;
-import org.apache.ignite.internal.pagememory.io.IoVersions;
 import org.apache.ignite.internal.pagememory.io.PageIo;
 
 /**
- * Io for partition metadata pages.
+ * base Io for partition metadata pages.

Review Comment:
   ```suggestion
    * Base Io for partition metadata pages.
   ```



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/PartitionMetaFactory.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.pagememory.persistence;
+
+import java.util.UUID;
+import org.apache.ignite.internal.pagememory.persistence.io.PartitionMetaIo;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Factory for creating {@link PartitionMeta} instances.
+ */
+public interface PartitionMetaFactory {
+    PartitionMeta createPartitionMeta(@Nullable UUID checkpointId, 
PartitionMetaIo metaIo, long pageAddr);

Review Comment:
   Javadocs are missing



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/io/PartitionMetaIo.java:
##########
@@ -19,213 +19,36 @@
 
 import static org.apache.ignite.internal.pagememory.PageIdAllocator.FLAG_AUX;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.getInt;
-import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.putInt;
-import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
 
-import org.apache.ignite.internal.hlc.HybridTimestamp;
 import org.apache.ignite.internal.lang.IgniteStringBuilder;
-import org.apache.ignite.internal.pagememory.io.IoVersions;
 import org.apache.ignite.internal.pagememory.io.PageIo;
 
 /**
- * Io for partition metadata pages.
+ * base Io for partition metadata pages.
  */
-public class PartitionMetaIo extends PageIo {
-    private static final int LAST_APPLIED_INDEX_OFF = COMMON_HEADER_END;
-
-    private static final int LAST_APPLIED_TERM_OFF = LAST_APPLIED_INDEX_OFF + 
Long.BYTES;
-
-    private static final int 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF = 
LAST_APPLIED_TERM_OFF + Long.BYTES;
-
-    private static final int FREE_LIST_ROOT_PAGE_ID_OFF = 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF + Long.BYTES;
-
-    private static final int VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF = 
FREE_LIST_ROOT_PAGE_ID_OFF + Long.BYTES;
-
-    public static final int INDEX_TREE_META_PAGE_ID_OFF = 
VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF + Long.BYTES;
-
-    private static final int GC_QUEUE_META_PAGE_ID_OFF = 
INDEX_TREE_META_PAGE_ID_OFF + Long.BYTES;
-
-    private static final int PAGE_COUNT_OFF = GC_QUEUE_META_PAGE_ID_OFF + 
Long.BYTES;
-
-    private static final int LEASE_START_TIME_OFF = PAGE_COUNT_OFF + 
Integer.BYTES;
-
+public abstract class PartitionMetaIo extends PageIo {
     /** Page IO type. */
     public static final short T_TABLE_PARTITION_META_IO = 7;

Review Comment:
   This must be defined in the concrete `PartitionMetaIo` implementation (as 
it's specific to it).



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/io/PartitionMetaIo.java:
##########
@@ -246,44 +69,14 @@ public void setPageCount(long pageAddr, int pageCount) {
      * @param pageAddr Page address.
      */
     public int getPageCount(long pageAddr) {
-        return getInt(pageAddr, PAGE_COUNT_OFF);
-    }
-
-    /**
-     * Sets the lease start time.
-     *
-     * @param pageAddr Page address.
-     * @param leaseStartTime Lease start time.
-     */
-    public void setLeaseStartTime(long pageAddr, long leaseStartTime) {
-        assertPageType(pageAddr);
-
-        putLong(pageAddr, LEASE_START_TIME_OFF, leaseStartTime);
-    }
-
-    /**
-     * Returns the lease start time.
-     *
-     * @param pageAddr Page address.
-     * @return Lease start time.
-     */
-    public long getLeaseStartTime(long pageAddr) {
-        return getLong(pageAddr, LEASE_START_TIME_OFF);
+        return getInt(pageAddr, getPageCountOff);
     }
 
     /** {@inheritDoc} */
     @Override
     protected void printPage(long addr, int pageSize, IgniteStringBuilder sb) {
         sb.app("TablePartitionMeta [").nl()

Review Comment:
   It's not about `TablePartitionMeta` anymore. Also, I'm not sure if this 
abstract class needs `printPage()` at all: wouldn't it be enough to have them 
in the specific classes?



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/StoragePartitionMeta.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * 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.storage.pagememory;
+
+import java.util.UUID;
+import org.apache.ignite.internal.pagememory.persistence.PartitionMeta;
+import org.apache.ignite.internal.pagememory.persistence.PartitionMetaFactory;
+import org.apache.ignite.internal.pagememory.persistence.io.PartitionMetaIo;
+import org.apache.ignite.internal.tostring.S;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
+
+/**
+ * Storage partition meta information.
+ */
+public class StoragePartitionMeta extends PartitionMeta {
+
+    public static final PartitionMetaFactory FACTORY = new 
StoragePartitionMetaFactory();
+
+    private volatile long lastAppliedIndex;
+
+    private volatile long lastAppliedTerm;
+
+    private volatile long leaseStartTime;
+
+    private volatile long lastReplicationProtocolGroupConfigFirstPageId;

Review Comment:
   Could you please change the order of these 2 fields? Those `last*` fields 
form a group logically, and `leaseStartTime` stands separately.



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/StoragePartitionMetaIo.java:
##########
@@ -0,0 +1,264 @@
+/*
+ * 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.storage.pagememory;
+
+import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
+import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
+
+import org.apache.ignite.internal.hlc.HybridTimestamp;
+import org.apache.ignite.internal.lang.IgniteStringBuilder;
+import org.apache.ignite.internal.pagememory.io.IoVersions;
+import org.apache.ignite.internal.pagememory.persistence.io.PartitionMetaIo;
+
+/**
+ * Storage Io for partition metadata pages.
+ */
+public class StoragePartitionMetaIo extends PartitionMetaIo {
+    private static final int LAST_APPLIED_INDEX_OFF = COMMON_HEADER_END;
+
+    private static final int LAST_APPLIED_TERM_OFF = LAST_APPLIED_INDEX_OFF + 
Long.BYTES;
+
+    private static final int 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF = 
LAST_APPLIED_TERM_OFF + Long.BYTES;
+
+    private static final int FREE_LIST_ROOT_PAGE_ID_OFF = 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF + Long.BYTES;
+
+    private static final int VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF = 
FREE_LIST_ROOT_PAGE_ID_OFF + Long.BYTES;
+
+    private static final int INDEX_TREE_META_PAGE_ID_OFF = 
VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF + Long.BYTES;
+
+    private static final int GC_QUEUE_META_PAGE_ID_OFF = 
INDEX_TREE_META_PAGE_ID_OFF + Long.BYTES;
+
+    private static final int PAGE_COUNT_OFF = GC_QUEUE_META_PAGE_ID_OFF + 
Long.BYTES;
+
+    private static final int LEASE_START_TIME_OFF = PAGE_COUNT_OFF + 
Integer.BYTES;
+
+
+    /** I/O versions. */
+    public static final IoVersions<StoragePartitionMetaIo> VERSIONS = new 
IoVersions<>(new StoragePartitionMetaIo(1));
+
+    /**
+     * Constructor.
+     *
+     * @param ver Page format version.
+     */
+    protected StoragePartitionMetaIo(int ver) {
+        super(ver, PAGE_COUNT_OFF);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void initNewPage(long pageAddr, long pageId, int pageSize) {
+        super.initNewPage(pageAddr, pageId, pageSize);
+
+        setLastAppliedIndex(pageAddr, 0);
+        setLastAppliedTerm(pageAddr, 0);
+        setLastReplicationProtocolGroupConfigFirstPageId(pageAddr, 0);
+        setFreeListRootPageId(pageAddr, 0);
+        setVersionChainTreeRootPageId(pageAddr, 0);
+        setIndexTreeMetaPageId(pageAddr, 0);
+        setGcQueueMetaPageId(pageAddr, 0);
+        setPageCount(pageAddr, 0);
+        setLeaseStartTime(pageAddr, HybridTimestamp.MIN_VALUE.longValue());
+    }
+
+    /**
+     * Sets a last applied index value.
+     *
+     * @param pageAddr Page address.
+     * @param lastAppliedIndex Last applied index value.
+     */
+    public void setLastAppliedIndex(long pageAddr, long lastAppliedIndex) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, LAST_APPLIED_INDEX_OFF, lastAppliedIndex);
+    }
+
+    /**
+     * Sets a last applied term value.
+     *
+     * @param pageAddr Page address.
+     * @param lastAppliedTerm Last applied term value.
+     */
+    public void setLastAppliedTerm(long pageAddr, long lastAppliedTerm) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, LAST_APPLIED_TERM_OFF, lastAppliedTerm);
+    }
+
+    /**
+     * Sets ID of the first page in a chain storing a blob representing last 
replication protocol group config.
+     *
+     * @param pageAddr Page address.
+     * @param pageId Page ID.
+     */
+    public void setLastReplicationProtocolGroupConfigFirstPageId(long 
pageAddr, long pageId) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF, pageId);
+    }
+
+    /**
+     * Returns a last applied index value.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getLastAppliedIndex(long pageAddr) {
+        return getLong(pageAddr, LAST_APPLIED_INDEX_OFF);
+    }
+
+    /**
+     * Returns a last applied term value.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getLastAppliedTerm(long pageAddr) {
+        return getLong(pageAddr, LAST_APPLIED_TERM_OFF);
+    }
+
+    /**
+     * Returns ID of the first page in a chain storing a blob representing 
last replication protocol group config.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getLastReplicationProtocolGroupConfigFirstPageId(long 
pageAddr) {
+        return getLong(pageAddr, 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF);
+    }
+
+    /**
+     * Sets free list root page ID.
+     *
+     * @param pageAddr Page address.
+     * @param pageId Free list root page ID.
+     */
+    public void setFreeListRootPageId(long pageAddr, long pageId) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, FREE_LIST_ROOT_PAGE_ID_OFF, pageId);
+    }
+
+    /**
+     * Returns free list root page ID.
+     *
+     * @param pageAddr Page address.
+     */
+    public static long getFreeListRootPageId(long pageAddr) {
+        return getLong(pageAddr, FREE_LIST_ROOT_PAGE_ID_OFF);
+    }
+
+    /**
+     * Sets version chain tree root page ID.
+     *
+     * @param pageAddr Page address.
+     * @param pageId Version chain tree root page ID.
+     */
+    public void setVersionChainTreeRootPageId(long pageAddr, long pageId) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF, pageId);
+    }
+
+    /**
+     * Returns version chain tree root page ID.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getVersionChainTreeRootPageId(long pageAddr) {
+        return getLong(pageAddr, VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF);
+    }
+
+    /**
+     * Sets an index meta tree meta page id.
+     *
+     * @param pageAddr Page address.
+     * @param pageId Meta page id.
+     */
+    public void setIndexTreeMetaPageId(long pageAddr, long pageId) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, INDEX_TREE_META_PAGE_ID_OFF, pageId);
+    }
+
+    /**
+     * Returns an index meta tree meta page id.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getIndexTreeMetaPageId(long pageAddr) {
+        return getLong(pageAddr, INDEX_TREE_META_PAGE_ID_OFF);
+    }
+
+    /**
+     * Sets a garbage collection queue meta page id.
+     *
+     * @param pageAddr Page address.
+     * @param pageId Meta page id.
+     */
+    public void setGcQueueMetaPageId(long pageAddr, long pageId) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, GC_QUEUE_META_PAGE_ID_OFF, pageId);
+    }
+
+    /**
+     * Returns an garbage collection queue meta page id.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getGcQueueMetaPageId(long pageAddr) {
+        return getLong(pageAddr, GC_QUEUE_META_PAGE_ID_OFF);
+    }
+
+
+    /**
+     * Sets the lease start time.
+     *
+     * @param pageAddr Page address.
+     * @param leaseStartTime Lease start time.
+     */
+    public void setLeaseStartTime(long pageAddr, long leaseStartTime) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, LEASE_START_TIME_OFF, leaseStartTime);
+    }
+
+    /**
+     * Returns the lease start time.
+     *
+     * @param pageAddr Page address.
+     * @return Lease start time.
+     */
+    public long getLeaseStartTime(long pageAddr) {
+        return getLong(pageAddr, LEASE_START_TIME_OFF);
+    }
+
+    /** {@inheritDoc} */

Review Comment:
   Please remove `inheritDoc`



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/StorageMemoryIoModule.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.storage.pagememory;
+
+import com.google.auto.service.AutoService;
+import java.util.Collection;
+import java.util.List;
+import org.apache.ignite.internal.pagememory.io.IoVersions;
+import org.apache.ignite.internal.pagememory.io.PageIoModule;
+
+/**
+ * {@link PageIoModule} implementation in storage-page-memory module.
+ */
+@AutoService(PageIoModule.class)
+public class StorageMemoryIoModule implements PageIoModule {
+    /** {@inheritDoc} */

Review Comment:
   We don't use `inheritDoc` in new code



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/io/PartitionMetaIo.java:
##########
@@ -19,213 +19,36 @@
 
 import static org.apache.ignite.internal.pagememory.PageIdAllocator.FLAG_AUX;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.getInt;
-import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.putInt;
-import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
 
-import org.apache.ignite.internal.hlc.HybridTimestamp;
 import org.apache.ignite.internal.lang.IgniteStringBuilder;
-import org.apache.ignite.internal.pagememory.io.IoVersions;
 import org.apache.ignite.internal.pagememory.io.PageIo;
 
 /**
- * Io for partition metadata pages.
+ * base Io for partition metadata pages.
  */
-public class PartitionMetaIo extends PageIo {
-    private static final int LAST_APPLIED_INDEX_OFF = COMMON_HEADER_END;
-
-    private static final int LAST_APPLIED_TERM_OFF = LAST_APPLIED_INDEX_OFF + 
Long.BYTES;
-
-    private static final int 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF = 
LAST_APPLIED_TERM_OFF + Long.BYTES;
-
-    private static final int FREE_LIST_ROOT_PAGE_ID_OFF = 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF + Long.BYTES;
-
-    private static final int VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF = 
FREE_LIST_ROOT_PAGE_ID_OFF + Long.BYTES;
-
-    public static final int INDEX_TREE_META_PAGE_ID_OFF = 
VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF + Long.BYTES;
-
-    private static final int GC_QUEUE_META_PAGE_ID_OFF = 
INDEX_TREE_META_PAGE_ID_OFF + Long.BYTES;
-
-    private static final int PAGE_COUNT_OFF = GC_QUEUE_META_PAGE_ID_OFF + 
Long.BYTES;
-
-    private static final int LEASE_START_TIME_OFF = PAGE_COUNT_OFF + 
Integer.BYTES;
-
+public abstract class PartitionMetaIo extends PageIo {
     /** Page IO type. */
     public static final short T_TABLE_PARTITION_META_IO = 7;
 
-    /** I/O versions. */
-    public static final IoVersions<PartitionMetaIo> VERSIONS = new 
IoVersions<>(new PartitionMetaIo(1));
+    private final int getPageCountOff;
 
     /**
      * Constructor.
      *
      * @param ver Page format version.
      */
-    protected PartitionMetaIo(int ver) {
+    protected PartitionMetaIo(int ver, int getPageCountOff) {

Review Comment:
   The constructor has to accept a parameter for page IO type instead of 
hardcoding it. It should be hardcoded in the concrete implementation.



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/io/PartitionMetaIo.java:
##########
@@ -19,213 +19,36 @@
 
 import static org.apache.ignite.internal.pagememory.PageIdAllocator.FLAG_AUX;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.getInt;
-import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.putInt;
-import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
 
-import org.apache.ignite.internal.hlc.HybridTimestamp;
 import org.apache.ignite.internal.lang.IgniteStringBuilder;
-import org.apache.ignite.internal.pagememory.io.IoVersions;
 import org.apache.ignite.internal.pagememory.io.PageIo;
 
 /**
- * Io for partition metadata pages.
+ * base Io for partition metadata pages.
  */
-public class PartitionMetaIo extends PageIo {
-    private static final int LAST_APPLIED_INDEX_OFF = COMMON_HEADER_END;
-
-    private static final int LAST_APPLIED_TERM_OFF = LAST_APPLIED_INDEX_OFF + 
Long.BYTES;
-
-    private static final int 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF = 
LAST_APPLIED_TERM_OFF + Long.BYTES;
-
-    private static final int FREE_LIST_ROOT_PAGE_ID_OFF = 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF + Long.BYTES;
-
-    private static final int VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF = 
FREE_LIST_ROOT_PAGE_ID_OFF + Long.BYTES;
-
-    public static final int INDEX_TREE_META_PAGE_ID_OFF = 
VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF + Long.BYTES;
-
-    private static final int GC_QUEUE_META_PAGE_ID_OFF = 
INDEX_TREE_META_PAGE_ID_OFF + Long.BYTES;
-
-    private static final int PAGE_COUNT_OFF = GC_QUEUE_META_PAGE_ID_OFF + 
Long.BYTES;
-
-    private static final int LEASE_START_TIME_OFF = PAGE_COUNT_OFF + 
Integer.BYTES;
-
+public abstract class PartitionMetaIo extends PageIo {
     /** Page IO type. */
     public static final short T_TABLE_PARTITION_META_IO = 7;
 
-    /** I/O versions. */
-    public static final IoVersions<PartitionMetaIo> VERSIONS = new 
IoVersions<>(new PartitionMetaIo(1));
+    private final int getPageCountOff;

Review Comment:
   ```suggestion
       private final int getPageCountOffset;
   ```



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/PersistentPageMemoryTableStorage.java:
##########
@@ -113,7 +113,7 @@ protected void finishDestruction() {
     public PersistentPageMemoryMvPartitionStorage createMvPartitionStorage(int 
partitionId) {
         GroupPartitionId groupPartitionId = 
createGroupPartitionId(partitionId);
 
-        PartitionMeta meta = 
getOrCreatePartitionMetaOnCreatePartition(groupPartitionId);
+        StoragePartitionMeta meta = (StoragePartitionMeta) 
getOrCreatePartitionMetaOnCreatePartition(groupPartitionId);

Review Comment:
   Let's move this cast inside `readOrCreatePartitionMeta()`, line 467:
   
   ```
   return 
dataRegion.partitionMetaManager().readOrCreateMeta(lastCheckpointId(), 
groupPartitionId, filePageStore, buffer);
   ```



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/PersistentPageMemoryTableStorage.java:
##########
@@ -336,7 +336,7 @@ CompletableFuture<Void> 
clearStorageAndUpdateDataStructures(AbstractPageMemoryMv
 
             int partitionId = groupPartitionId.getPartitionId();
 
-            PartitionMeta meta = 
getOrCreatePartitionMetaOnCreatePartition(groupPartitionId);
+            StoragePartitionMeta meta = (StoragePartitionMeta) 
getOrCreatePartitionMetaOnCreatePartition(groupPartitionId);

Review Comment:
   Let's move this cast in the same way



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/StoragePartitionMetaIo.java:
##########
@@ -0,0 +1,264 @@
+/*
+ * 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.storage.pagememory;
+
+import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
+import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
+
+import org.apache.ignite.internal.hlc.HybridTimestamp;
+import org.apache.ignite.internal.lang.IgniteStringBuilder;
+import org.apache.ignite.internal.pagememory.io.IoVersions;
+import org.apache.ignite.internal.pagememory.persistence.io.PartitionMetaIo;
+
+/**
+ * Storage Io for partition metadata pages.
+ */
+public class StoragePartitionMetaIo extends PartitionMetaIo {
+    private static final int LAST_APPLIED_INDEX_OFF = COMMON_HEADER_END;
+
+    private static final int LAST_APPLIED_TERM_OFF = LAST_APPLIED_INDEX_OFF + 
Long.BYTES;
+
+    private static final int 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF = 
LAST_APPLIED_TERM_OFF + Long.BYTES;
+
+    private static final int FREE_LIST_ROOT_PAGE_ID_OFF = 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF + Long.BYTES;
+
+    private static final int VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF = 
FREE_LIST_ROOT_PAGE_ID_OFF + Long.BYTES;
+
+    private static final int INDEX_TREE_META_PAGE_ID_OFF = 
VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF + Long.BYTES;
+
+    private static final int GC_QUEUE_META_PAGE_ID_OFF = 
INDEX_TREE_META_PAGE_ID_OFF + Long.BYTES;
+
+    private static final int PAGE_COUNT_OFF = GC_QUEUE_META_PAGE_ID_OFF + 
Long.BYTES;
+
+    private static final int LEASE_START_TIME_OFF = PAGE_COUNT_OFF + 
Integer.BYTES;
+
+
+    /** I/O versions. */
+    public static final IoVersions<StoragePartitionMetaIo> VERSIONS = new 
IoVersions<>(new StoragePartitionMetaIo(1));
+
+    /**
+     * Constructor.
+     *
+     * @param ver Page format version.
+     */
+    protected StoragePartitionMetaIo(int ver) {
+        super(ver, PAGE_COUNT_OFF);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void initNewPage(long pageAddr, long pageId, int pageSize) {
+        super.initNewPage(pageAddr, pageId, pageSize);
+
+        setLastAppliedIndex(pageAddr, 0);
+        setLastAppliedTerm(pageAddr, 0);
+        setLastReplicationProtocolGroupConfigFirstPageId(pageAddr, 0);
+        setFreeListRootPageId(pageAddr, 0);
+        setVersionChainTreeRootPageId(pageAddr, 0);
+        setIndexTreeMetaPageId(pageAddr, 0);
+        setGcQueueMetaPageId(pageAddr, 0);
+        setPageCount(pageAddr, 0);
+        setLeaseStartTime(pageAddr, HybridTimestamp.MIN_VALUE.longValue());
+    }
+
+    /**
+     * Sets a last applied index value.
+     *
+     * @param pageAddr Page address.
+     * @param lastAppliedIndex Last applied index value.
+     */
+    public void setLastAppliedIndex(long pageAddr, long lastAppliedIndex) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, LAST_APPLIED_INDEX_OFF, lastAppliedIndex);
+    }
+
+    /**
+     * Sets a last applied term value.
+     *
+     * @param pageAddr Page address.
+     * @param lastAppliedTerm Last applied term value.
+     */
+    public void setLastAppliedTerm(long pageAddr, long lastAppliedTerm) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, LAST_APPLIED_TERM_OFF, lastAppliedTerm);
+    }
+
+    /**
+     * Sets ID of the first page in a chain storing a blob representing last 
replication protocol group config.
+     *
+     * @param pageAddr Page address.
+     * @param pageId Page ID.
+     */
+    public void setLastReplicationProtocolGroupConfigFirstPageId(long 
pageAddr, long pageId) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF, pageId);
+    }
+
+    /**
+     * Returns a last applied index value.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getLastAppliedIndex(long pageAddr) {
+        return getLong(pageAddr, LAST_APPLIED_INDEX_OFF);
+    }
+
+    /**
+     * Returns a last applied term value.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getLastAppliedTerm(long pageAddr) {
+        return getLong(pageAddr, LAST_APPLIED_TERM_OFF);
+    }
+
+    /**
+     * Returns ID of the first page in a chain storing a blob representing 
last replication protocol group config.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getLastReplicationProtocolGroupConfigFirstPageId(long 
pageAddr) {
+        return getLong(pageAddr, 
LAST_REPLICATION_PROTOCOL_GROUP_CONFIG_FIRST_PAGE_ID_OFF);
+    }
+
+    /**
+     * Sets free list root page ID.
+     *
+     * @param pageAddr Page address.
+     * @param pageId Free list root page ID.
+     */
+    public void setFreeListRootPageId(long pageAddr, long pageId) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, FREE_LIST_ROOT_PAGE_ID_OFF, pageId);
+    }
+
+    /**
+     * Returns free list root page ID.
+     *
+     * @param pageAddr Page address.
+     */
+    public static long getFreeListRootPageId(long pageAddr) {
+        return getLong(pageAddr, FREE_LIST_ROOT_PAGE_ID_OFF);
+    }
+
+    /**
+     * Sets version chain tree root page ID.
+     *
+     * @param pageAddr Page address.
+     * @param pageId Version chain tree root page ID.
+     */
+    public void setVersionChainTreeRootPageId(long pageAddr, long pageId) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF, pageId);
+    }
+
+    /**
+     * Returns version chain tree root page ID.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getVersionChainTreeRootPageId(long pageAddr) {
+        return getLong(pageAddr, VERSION_CHAIN_TREE_ROOT_PAGE_ID_OFF);
+    }
+
+    /**
+     * Sets an index meta tree meta page id.
+     *
+     * @param pageAddr Page address.
+     * @param pageId Meta page id.
+     */
+    public void setIndexTreeMetaPageId(long pageAddr, long pageId) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, INDEX_TREE_META_PAGE_ID_OFF, pageId);
+    }
+
+    /**
+     * Returns an index meta tree meta page id.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getIndexTreeMetaPageId(long pageAddr) {
+        return getLong(pageAddr, INDEX_TREE_META_PAGE_ID_OFF);
+    }
+
+    /**
+     * Sets a garbage collection queue meta page id.
+     *
+     * @param pageAddr Page address.
+     * @param pageId Meta page id.
+     */
+    public void setGcQueueMetaPageId(long pageAddr, long pageId) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, GC_QUEUE_META_PAGE_ID_OFF, pageId);
+    }
+
+    /**
+     * Returns an garbage collection queue meta page id.
+     *
+     * @param pageAddr Page address.
+     */
+    public long getGcQueueMetaPageId(long pageAddr) {
+        return getLong(pageAddr, GC_QUEUE_META_PAGE_ID_OFF);
+    }
+

Review Comment:
   Extra line



##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/TestPartitionMeta.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.pagememory.persistence;
+
+import java.util.UUID;
+import org.apache.ignite.internal.pagememory.io.IoVersions;
+import org.apache.ignite.internal.pagememory.persistence.io.PartitionMetaIo;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Simple implementation of {@link PartitionMeta} for testing purposes.
+ */
+public class TestPartitionMeta extends PartitionMeta {

Review Comment:
   How about using 'fake' instead of 'test' here? As this meta does not write 
itself anywhere.



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/PartitionMeta.java:
##########
@@ -46,212 +45,33 @@ public class PartitionMeta {
         }
     }
 
-    private volatile long lastAppliedIndex;
-
-    private volatile long lastAppliedTerm;
-
-    private volatile long leaseStartTime;
-
-    private volatile long lastReplicationProtocolGroupConfigFirstPageId;
-
-    private volatile long freeListRootPageId;
-
-    private volatile long versionChainTreeRootPageId;
-
-    private volatile long indexTreeMetaPageId;
-
-    private volatile long gcQueueMetaPageId;
+    protected volatile PartitionMetaSnapshot metaSnapshot;

Review Comment:
   It seems that this field can be `private`



-- 
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