xtern commented on a change in pull request #7941:
URL: https://github.com/apache/ignite/pull/7941#discussion_r496481051



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionMetaIOV3.java
##########
@@ -0,0 +1,137 @@
+/*
+ * 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.processors.cache.persistence.tree.io;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.pagemem.PageUtils;
+import 
org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState;
+import org.apache.ignite.internal.util.GridStringBuilder;
+
+/**
+ * IO for partition metadata pages.
+ * Persistent partition contains it's own PendingTree.
+ */
+public class PagePartitionMetaIOV3 extends PagePartitionMetaIOV2 {
+    /** Last reencrypted page index offset. */
+    private static final int ENCRYPT_PAGE_IDX_OFF = 
END_OF_PARTITION_PAGE_META_V2;
+
+    /** Total pages to be reencrypted offset. */
+    private static final int ENCRYPT_PAGE_MAX_OFF = ENCRYPT_PAGE_IDX_OFF + 4;
+
+    /**
+     * @param ver Version.
+     */
+    public PagePartitionMetaIOV3(int ver) {
+        super(ver);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void initNewPage(long pageAddr, long pageId, int 
pageSize) {
+        super.initNewPage(pageAddr, pageId, pageSize);
+
+        setEncryptedPageIndex(pageAddr, 0);
+        setEncryptedPageCount(pageAddr, 0);
+    }
+
+    /**
+     * @param pageAddr Page address.
+     * @return Index of the last reencrypted page.
+     */
+    public int getEncryptedPageIndex(long pageAddr) {
+        return PageUtils.getInt(pageAddr, ENCRYPT_PAGE_IDX_OFF);
+    }
+
+    /**
+     * @param pageAddr Page address.
+     * @param pageIdx Index of the last reencrypted page.
+     *
+     * @return {@code true} if value has changed as a result of this method's 
invocation.
+     */
+    public boolean setEncryptedPageIndex(long pageAddr, int pageIdx) {
+        if (getEncryptedPageIndex(pageAddr) == pageIdx)
+            return false;
+
+        PageUtils.putLong(pageAddr, ENCRYPT_PAGE_IDX_OFF, pageIdx);
+
+        return true;
+    }
+
+    /**
+     * @param pageAddr Page address.
+     * @return Total pages to be reencrypted.
+     */
+    public int getEncryptedPageCount(long pageAddr) {
+        return PageUtils.getInt(pageAddr, ENCRYPT_PAGE_MAX_OFF);
+    }
+
+    /**
+     * @param pageAddr Page address.
+     * @param pagesCnt Total pages to be reencrypted.
+     *
+     * @return {@code true} if value has changed as a result of this method's 
invocation.
+     */
+    public boolean setEncryptedPageCount(long pageAddr, int pagesCnt) {
+        if (getEncryptedPageCount(pageAddr) == pagesCnt)
+            return false;
+
+        PageUtils.putInt(pageAddr, ENCRYPT_PAGE_MAX_OFF, pagesCnt);
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void printPage(long pageAddr, int pageSize, 
GridStringBuilder sb) throws IgniteCheckedException {

Review comment:
       added additional method to print fields.




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

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


Reply via email to