sashapolo commented on a change in pull request #566:
URL: https://github.com/apache/ignite-3/pull/566#discussion_r788811202



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
##########
@@ -261,6 +262,26 @@ private static void addByteAsHex(StringBuilder sb, byte b) 
{
         sb.append(Integer.toHexString(MASK & b >>> 
4)).append(Integer.toHexString(MASK & b));
     }
 
+    /**
+     * Returns a hex string representation of the given long value.
+     *
+     * @param val Value to convert to string.
+     * @return Hex string.
+     */
+    public static String hexLong(long val) {
+        return new IgniteStringBuilder(16).appendHex(val).toString();
+    }
+
+    /**
+     * Rtturns a hex string representation of the given integer value.

Review comment:
       ```suggestion
        * Returns a hex string representation of the given integer value.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and
+ * flags. Higher 8 bits of page ID are unused and reserved to address entries 
inside data pages or page ID rotation.
+ *
+ * <p>Partition ID {@code 0xFFFF} is reserved for index pages.
+ *
+ * <p>The structure of a page ID is shown in the diagram below:
+ * <pre>
+ * +---------+-----------+------------+--------------------------+
+ * | 8 bits  |   8 bits  |  16 bits   |         32 bits          |
+ * +---------+-----------+------------+--------------------------+
+ * |  OFFSET |   FLAGS   |PARTITION ID|       PAGE INDEX         |
+ * +---------+-----------+------------+--------------------------+
+ * </pre>
+ *
+ * <p><h3>Page ID rotation</h3>

Review comment:
       ```suggestion
    * <h3>Page ID rotation</h3>
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and
+ * flags. Higher 8 bits of page ID are unused and reserved to address entries 
inside data pages or page ID rotation.

Review comment:
       ```suggestion
    * flags (8 bits). Higher 8 bits of page ID are unused and reserved to 
address entries inside data pages or page ID rotation.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and
+ * flags. Higher 8 bits of page ID are unused and reserved to address entries 
inside data pages or page ID rotation.
+ *
+ * <p>Partition ID {@code 0xFFFF} is reserved for index pages.
+ *
+ * <p>The structure of a page ID is shown in the diagram below:
+ * <pre>
+ * +---------+-----------+------------+--------------------------+
+ * | 8 bits  |   8 bits  |  16 bits   |         32 bits          |
+ * +---------+-----------+------------+--------------------------+
+ * |  OFFSET |   FLAGS   |PARTITION ID|       PAGE INDEX         |
+ * +---------+-----------+------------+--------------------------+
+ * </pre>
+ *
+ * <p><h3>Page ID rotation</h3>
+ * There are scenarios when we reference one page (B) from within another page 
(A) by page ID. It is also
+ * possible that this first page (B) is concurrently reused for a different 
purpose. In this
+ * case we should have a mechanism to determine that the reference from page 
(A) to page (B) is no longer valid.
+ * This is ensured by page ID rotation - together with page's (B) ID we should 
write some value that is incremented
+ * each time a page is reused (page ID rotation). This ID should be verified 
after page read and a page
+ * should be discarded if full ID is different.
+ *
+ * <p>Effective page ID is page ID with zeroed bits used for page ID rotation.
+ */
+public class FullPageId {
+    /** Null page ID. */

Review comment:
       What is a "Null page"?

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageIdAllocator.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Allocates page ID's.
+ */
+public interface PageIdAllocator {
+    /**
+     * Flag for a Data page. Also used by partition meta and tracking pages. 
This type doesn't use the Page ID rotation mechanism.
+     */
+    public static final byte FLAG_DATA = 1;
+
+    /**
+     * Flag for an internal structure page. This type uses the Page ID 
rotation mechanism.
+     */
+    public static final byte FLAG_AUX = 2;
+
+    /**
+     * Max partition ID that can be used by affinity.
+     */
+    public static final int MAX_PARTITION_ID = 65500;
+
+    /**
+     * Special partition reserved for index space.
+     */
+    public static final int INDEX_PARTITION = 0xFFFF;
+
+    /**
+     * Allocates a page from the space for the given partition ID and the 
given flags.
+     *
+     * @param groupId Group ID.
+     * @param partId  Partition ID.
+     * @return Allocated page ID.
+     */
+    public long allocatePage(int groupId, int partId, byte flags) throws 
IgniteInternalCheckedException;
+
+    /**
+     * The given page is free now.

Review comment:
       ```suggestion
        * Frees (deallocates?) the given page.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageMemory.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.pagememory.io.PageIo;
+import org.apache.ignite.internal.pagememory.io.PageIoRegistry;
+
+/**
+ * Page memory.
+ */
+public interface PageMemory extends PageIdAllocator, PageSupport {
+    /**
+     * Returns a page size in bytes.

Review comment:
       ```suggestion
        * Returns a page's size in bytes.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageMemory.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.pagememory.io.PageIo;
+import org.apache.ignite.internal.pagememory.io.PageIoRegistry;
+
+/**
+ * Page memory.
+ */
+public interface PageMemory extends PageIdAllocator, PageSupport {
+    /**
+     * Returns a page size in bytes.
+     */
+    int pageSize();
+
+    /**
+     * Returns a page size without encryption overhead.
+     *
+     * @param groupId Group id.
+     */
+    int realPageSize(int groupId);
+
+    /**
+     * Returns a page size with system overhead, in bytes.
+     */
+    int systemPageSize();
+
+    /**
+     * Wraps a page address into a direct byte buffer.
+     *
+     * @param pageAddr Page address.
+     * @return Page byte buffer.
+     */
+    ByteBuffer pageBuffer(long pageAddr);

Review comment:
       what is a page address? Is it an index or is it an ID or is it something 
else? We should add a reference to the method that returns these addresses

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.

Review comment:
       ```suggestion
        * {@link #releasePage(int, long, long)}. This method will allocate a 
page with the given ID if it doesn't exist.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling

Review comment:
       ```suggestion
        * Returns an absolute pointer to a page, associated with the given page 
ID. Each page obtained with this method must be released by calling
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and

Review comment:
       ```suggestion
    * <p>Generally, a full page ID consists of a group ID and a page ID. A page 
ID consists of a page index (32 bits), a partition ID (16 bits) and
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and
+ * flags. Higher 8 bits of page ID are unused and reserved to address entries 
inside data pages or page ID rotation.
+ *
+ * <p>Partition ID {@code 0xFFFF} is reserved for index pages.
+ *
+ * <p>The structure of a page ID is shown in the diagram below:
+ * <pre>
+ * +---------+-----------+------------+--------------------------+
+ * | 8 bits  |   8 bits  |  16 bits   |         32 bits          |
+ * +---------+-----------+------------+--------------------------+
+ * |  OFFSET |   FLAGS   |PARTITION ID|       PAGE INDEX         |
+ * +---------+-----------+------------+--------------------------+
+ * </pre>
+ *
+ * <p><h3>Page ID rotation</h3>
+ * There are scenarios when we reference one page (B) from within another page 
(A) by page ID. It is also
+ * possible that this first page (B) is concurrently reused for a different 
purpose. In this
+ * case we should have a mechanism to determine that the reference from page 
(A) to page (B) is no longer valid.
+ * This is ensured by page ID rotation - together with page's (B) ID we should 
write some value that is incremented
+ * each time a page is reused (page ID rotation). This ID should be verified 
after page read and a page

Review comment:
       ```suggestion
    * each time a page is reused. This value should be verified after every 
page read and the page
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and
+ * flags. Higher 8 bits of page ID are unused and reserved to address entries 
inside data pages or page ID rotation.
+ *
+ * <p>Partition ID {@code 0xFFFF} is reserved for index pages.
+ *
+ * <p>The structure of a page ID is shown in the diagram below:
+ * <pre>
+ * +---------+-----------+------------+--------------------------+
+ * | 8 bits  |   8 bits  |  16 bits   |         32 bits          |
+ * +---------+-----------+------------+--------------------------+
+ * |  OFFSET |   FLAGS   |PARTITION ID|       PAGE INDEX         |
+ * +---------+-----------+------------+--------------------------+
+ * </pre>
+ *
+ * <p><h3>Page ID rotation</h3>
+ * There are scenarios when we reference one page (B) from within another page 
(A) by page ID. It is also
+ * possible that this first page (B) is concurrently reused for a different 
purpose. In this
+ * case we should have a mechanism to determine that the reference from page 
(A) to page (B) is no longer valid.
+ * This is ensured by page ID rotation - together with page's (B) ID we should 
write some value that is incremented
+ * each time a page is reused (page ID rotation). This ID should be verified 
after page read and a page
+ * should be discarded if full ID is different.

Review comment:
       ```suggestion
    * should be discarded if the full ID is different.
   ```

##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
##########
@@ -261,6 +262,26 @@ private static void addByteAsHex(StringBuilder sb, byte b) 
{
         sb.append(Integer.toHexString(MASK & b >>> 
4)).append(Integer.toHexString(MASK & b));
     }
 
+    /**
+     * Returns a hex string representation of the given long value.
+     *
+     * @param val Value to convert to string.
+     * @return Hex string.
+     */
+    public static String hexLong(long val) {

Review comment:
       I would suggest extracting this and similar method to something like 
`IgniteStringUtils`, otherwise this class is getting too bloated

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and
+ * flags. Higher 8 bits of page ID are unused and reserved to address entries 
inside data pages or page ID rotation.

Review comment:
       ```suggestion
    * flags. Higher 8 bits of a page ID are unused and reserved for addressing 
entries inside data pages or for page ID rotation.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageMemory.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.pagememory.io.PageIo;
+import org.apache.ignite.internal.pagememory.io.PageIoRegistry;
+
+/**
+ * Page memory.
+ */
+public interface PageMemory extends PageIdAllocator, PageSupport {
+    /**
+     * Returns a page size in bytes.
+     */
+    int pageSize();
+
+    /**
+     * Returns a page size without encryption overhead.

Review comment:
       Maybe it would be a good idea to rename this method...

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and
+ * flags. Higher 8 bits of page ID are unused and reserved to address entries 
inside data pages or page ID rotation.
+ *
+ * <p>Partition ID {@code 0xFFFF} is reserved for index pages.
+ *
+ * <p>The structure of a page ID is shown in the diagram below:
+ * <pre>
+ * +---------+-----------+------------+--------------------------+
+ * | 8 bits  |   8 bits  |  16 bits   |         32 bits          |
+ * +---------+-----------+------------+--------------------------+
+ * |  OFFSET |   FLAGS   |PARTITION ID|       PAGE INDEX         |
+ * +---------+-----------+------------+--------------------------+
+ * </pre>
+ *
+ * <p><h3>Page ID rotation</h3>
+ * There are scenarios when we reference one page (B) from within another page 
(A) by page ID. It is also
+ * possible that this first page (B) is concurrently reused for a different 
purpose. In this
+ * case we should have a mechanism to determine that the reference from page 
(A) to page (B) is no longer valid.
+ * This is ensured by page ID rotation - together with page's (B) ID we should 
write some value that is incremented
+ * each time a page is reused (page ID rotation). This ID should be verified 
after page read and a page
+ * should be discarded if full ID is different.
+ *
+ * <p>Effective page ID is page ID with zeroed bits used for page ID rotation.

Review comment:
       ```suggestion
    * <p>Effective page ID is a page ID with zeroed bits used for page ID 
rotation.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId    Group ID.
+     * @param pageId     Page ID.
+     * @param statHolder Statistics holder to track IO operations.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId, IoStatisticsHolder 
statHolder) throws IgniteInternalCheckedException;
+
+    /**
+     * Releases page acquired by one of {@code acquirePage} methods.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID to release.
+     * @param page    Page pointer returned by the corresponding {@code 
acquirePage} call.
+     */
+    public void releasePage(int groupId, long pageId, long page);
+
+    /**
+     * Acquires a read lock on the page.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @param page    Page pointer.
+     * @return Pointer for reading the page or {@code 0} if page has been 
reused.
+     */
+    public long readLock(int groupId, long pageId, long page);
+
+    /**
+     * Obtains read lock without checking page tag.

Review comment:
       And what is a page tag?

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and
+ * flags. Higher 8 bits of page ID are unused and reserved to address entries 
inside data pages or page ID rotation.
+ *
+ * <p>Partition ID {@code 0xFFFF} is reserved for index pages.
+ *
+ * <p>The structure of a page ID is shown in the diagram below:
+ * <pre>
+ * +---------+-----------+------------+--------------------------+
+ * | 8 bits  |   8 bits  |  16 bits   |         32 bits          |
+ * +---------+-----------+------------+--------------------------+
+ * |  OFFSET |   FLAGS   |PARTITION ID|       PAGE INDEX         |
+ * +---------+-----------+------------+--------------------------+
+ * </pre>
+ *
+ * <p><h3>Page ID rotation</h3>
+ * There are scenarios when we reference one page (B) from within another page 
(A) by page ID. It is also
+ * possible that this first page (B) is concurrently reused for a different 
purpose. In this
+ * case we should have a mechanism to determine that the reference from page 
(A) to page (B) is no longer valid.
+ * This is ensured by page ID rotation - together with page's (B) ID we should 
write some value that is incremented

Review comment:
       ```suggestion
    * This is ensured by page ID rotation - together with the ID of page B we 
write a value that is incremented
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and

Review comment:
       What is a "group ID"?

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageIdAllocator.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Allocates page ID's.
+ */
+public interface PageIdAllocator {
+    /**
+     * Flag for a Data page. Also used by partition meta and tracking pages. 
This type doesn't use the Page ID rotation mechanism.
+     */
+    public static final byte FLAG_DATA = 1;
+
+    /**
+     * Flag for an internal structure page. This type uses the Page ID 
rotation mechanism.
+     */
+    public static final byte FLAG_AUX = 2;
+
+    /**
+     * Max partition ID that can be used by affinity.
+     */
+    public static final int MAX_PARTITION_ID = 65500;
+
+    /**
+     * Special partition reserved for index space.

Review comment:
       ```suggestion
        * Special partition reserved for the index space.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageIdAllocator.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Allocates page ID's.

Review comment:
       ```suggestion
    * Class responsible for allocating new page IDs.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and
+ * flags. Higher 8 bits of page ID are unused and reserved to address entries 
inside data pages or page ID rotation.
+ *
+ * <p>Partition ID {@code 0xFFFF} is reserved for index pages.
+ *
+ * <p>The structure of a page ID is shown in the diagram below:
+ * <pre>
+ * +---------+-----------+------------+--------------------------+
+ * | 8 bits  |   8 bits  |  16 bits   |         32 bits          |
+ * +---------+-----------+------------+--------------------------+
+ * |  OFFSET |   FLAGS   |PARTITION ID|       PAGE INDEX         |
+ * +---------+-----------+------------+--------------------------+
+ * </pre>
+ *
+ * <p><h3>Page ID rotation</h3>
+ * There are scenarios when we reference one page (B) from within another page 
(A) by page ID. It is also
+ * possible that this first page (B) is concurrently reused for a different 
purpose. In this
+ * case we should have a mechanism to determine that the reference from page 
(A) to page (B) is no longer valid.
+ * This is ensured by page ID rotation - together with page's (B) ID we should 
write some value that is incremented
+ * each time a page is reused (page ID rotation). This ID should be verified 
after page read and a page
+ * should be discarded if full ID is different.
+ *
+ * <p>Effective page ID is page ID with zeroed bits used for page ID rotation.
+ */
+public class FullPageId {
+    /** Null page ID. */
+    public static final FullPageId NULL_PAGE = new FullPageId(-1, -1);
+
+    /** Page ID. */
+    private final long pageId;
+
+    /** Effective page ID. */
+    private final long effectivePageId;
+
+    /** Group ID. */
+    private final int groupId;
+
+    /**
+     * Constructor.
+     *
+     * @param pageId  Page ID.
+     * @param groupId Group ID.
+     */
+    public FullPageId(long pageId, int groupId) {
+        this.pageId = pageId;
+        this.groupId = groupId;
+
+        effectivePageId = PageIdUtils.effectivePageId(pageId);
+    }
+
+    /**
+     * Returns a page ID.
+     */
+    public long pageId() {
+        return pageId;
+    }
+
+    /**
+     * Returns an effective page ID.
+     */
+    public long effectivePageId() {
+        return effectivePageId;
+    }
+
+    /**
+     * Returns a group ID.
+     */
+    public int groupId() {
+        return groupId;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (!(o instanceof FullPageId)) {
+            return false;
+        }
+
+        FullPageId that = (FullPageId) o;
+
+        return effectivePageId == that.effectivePageId && groupId == 
that.groupId;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public int hashCode() {
+        return hashCode0(groupId, effectivePageId);
+    }
+
+    /**
+     * Returns hash code of the ID.

Review comment:
       What's the difference between this method and `hashCode()`?

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and
+ * flags. Higher 8 bits of page ID are unused and reserved to address entries 
inside data pages or page ID rotation.
+ *
+ * <p>Partition ID {@code 0xFFFF} is reserved for index pages.
+ *
+ * <p>The structure of a page ID is shown in the diagram below:
+ * <pre>
+ * +---------+-----------+------------+--------------------------+
+ * | 8 bits  |   8 bits  |  16 bits   |         32 bits          |
+ * +---------+-----------+------------+--------------------------+
+ * |  OFFSET |   FLAGS   |PARTITION ID|       PAGE INDEX         |

Review comment:
       Should we change `OFFSET` to `RESERVED`?

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageIdAllocator.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Allocates page ID's.
+ */
+public interface PageIdAllocator {
+    /**
+     * Flag for a Data page. Also used by partition meta and tracking pages. 
This type doesn't use the Page ID rotation mechanism.
+     */
+    public static final byte FLAG_DATA = 1;
+
+    /**
+     * Flag for an internal structure page. This type uses the Page ID 
rotation mechanism.
+     */
+    public static final byte FLAG_AUX = 2;
+
+    /**
+     * Max partition ID that can be used by affinity.

Review comment:
       This sentence makes little sense to me, can we improve it?

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageIdAllocator.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Allocates page ID's.
+ */
+public interface PageIdAllocator {
+    /**
+     * Flag for a Data page. Also used by partition meta and tracking pages. 
This type doesn't use the Page ID rotation mechanism.
+     */
+    public static final byte FLAG_DATA = 1;
+
+    /**
+     * Flag for an internal structure page. This type uses the Page ID 
rotation mechanism.
+     */
+    public static final byte FLAG_AUX = 2;
+
+    /**
+     * Max partition ID that can be used by affinity.
+     */
+    public static final int MAX_PARTITION_ID = 65500;
+
+    /**
+     * Special partition reserved for index space.
+     */
+    public static final int INDEX_PARTITION = 0xFFFF;
+
+    /**
+     * Allocates a page from the space for the given partition ID and the 
given flags.
+     *
+     * @param groupId Group ID.
+     * @param partId  Partition ID.
+     * @return Allocated page ID.
+     */
+    public long allocatePage(int groupId, int partId, byte flags) throws 
IgniteInternalCheckedException;

Review comment:
       Should we accept a `FullPageId` here and in other methods?

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/FullPageId.java
##########
@@ -0,0 +1,176 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteStringBuilder;
+
+/**
+ * Compound object used to address a page in the global page space.
+ * <h3>Page ID structure</h3>
+ *
+ * <p>Generally, a full page ID consists of a group ID and page ID. A page ID 
consists of page index (32 bits), partition ID (16 bits) and

Review comment:
       What is a "page index"?

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageMemory.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.pagememory.io.PageIo;
+import org.apache.ignite.internal.pagememory.io.PageIoRegistry;
+
+/**
+ * Page memory.

Review comment:
       I'm sorry, but this is not a good javadoc

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageMemory.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.pagememory.io.PageIo;
+import org.apache.ignite.internal.pagememory.io.PageIoRegistry;
+
+/**
+ * Page memory.
+ */
+public interface PageMemory extends PageIdAllocator, PageSupport {
+    /**
+     * Returns a page size in bytes.
+     */
+    int pageSize();
+
+    /**
+     * Returns a page size without encryption overhead.
+     *
+     * @param groupId Group id.
+     */
+    int realPageSize(int groupId);
+
+    /**
+     * Returns a page size with system overhead, in bytes.
+     */
+    int systemPageSize();

Review comment:
       Same here, I think this method should be renamed, because otherwise it 
creates an impression that it returns the size of a "system page"

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageMemory.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.pagememory.io.PageIo;
+import org.apache.ignite.internal.pagememory.io.PageIoRegistry;
+
+/**
+ * Page memory.
+ */
+public interface PageMemory extends PageIdAllocator, PageSupport {
+    /**
+     * Returns a page size in bytes.
+     */
+    int pageSize();
+
+    /**
+     * Returns a page size without encryption overhead.
+     *
+     * @param groupId Group id.
+     */
+    int realPageSize(int groupId);
+
+    /**
+     * Returns a page size with system overhead, in bytes.

Review comment:
       ```suggestion
        * Returns a page's size with system overhead, in bytes.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageMemory.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.pagememory.io.PageIo;
+import org.apache.ignite.internal.pagememory.io.PageIoRegistry;
+
+/**
+ * Page memory.
+ */
+public interface PageMemory extends PageIdAllocator, PageSupport {
+    /**
+     * Returns a page size in bytes.
+     */
+    int pageSize();
+
+    /**
+     * Returns a page size without encryption overhead.

Review comment:
       ```suggestion
        * Returns a page size without the encryption overhead.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageMemory.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.pagememory.io.PageIo;
+import org.apache.ignite.internal.pagememory.io.PageIoRegistry;
+
+/**
+ * Page memory.
+ */
+public interface PageMemory extends PageIdAllocator, PageSupport {
+    /**
+     * Returns a page size in bytes.
+     */
+    int pageSize();
+
+    /**
+     * Returns a page size without encryption overhead.
+     *
+     * @param groupId Group id.
+     */
+    int realPageSize(int groupId);
+
+    /**
+     * Returns a page size with system overhead, in bytes.
+     */
+    int systemPageSize();
+
+    /**
+     * Wraps a page address into a direct byte buffer.
+     *
+     * @param pageAddr Page address.
+     * @return Page byte buffer.
+     */
+    ByteBuffer pageBuffer(long pageAddr);
+
+    /**
+     * Returns a total number of loaded pages in memory.

Review comment:
       ```suggestion
        * Returns the total number of pages loaded into memory.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling

Review comment:
       ```suggestion
        * Returns an absolute pointer to a page, associated with the given page 
ID. Each pointer obtained with this method must be released by calling
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.

Review comment:
       I'm sorry, but this is also not a good javadoc

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.

Review comment:
       ```suggestion
        * {@link #releasePage(int, long, long)}. This method will allocate a 
page with the given ID if it doesn't exist.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageMemory.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.pagememory.io.PageIo;
+import org.apache.ignite.internal.pagememory.io.PageIoRegistry;
+
+/**
+ * Page memory.
+ */
+public interface PageMemory extends PageIdAllocator, PageSupport {
+    /**
+     * Returns a page size in bytes.
+     */
+    int pageSize();
+
+    /**
+     * Returns a page size without encryption overhead.
+     *
+     * @param groupId Group id.
+     */
+    int realPageSize(int groupId);
+
+    /**
+     * Returns a page size with system overhead, in bytes.
+     */
+    int systemPageSize();
+
+    /**
+     * Wraps a page address into a direct byte buffer.
+     *
+     * @param pageAddr Page address.
+     * @return Page byte buffer.
+     */
+    ByteBuffer pageBuffer(long pageAddr);
+
+    /**
+     * Returns a total number of loaded pages in memory.
+     */
+    long loadedPages();
+
+    /**
+     * Returns a registry to retrieve {@link PageIo} instances for pages.

Review comment:
       ```suggestion
        * Returns a registry to obtain {@link PageIo} instances for pages.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId    Group ID.
+     * @param pageId     Page ID.
+     * @param statHolder Statistics holder to track IO operations.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId, IoStatisticsHolder 
statHolder) throws IgniteInternalCheckedException;
+
+    /**
+     * Releases page acquired by one of {@code acquirePage} methods.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID to release.
+     * @param page    Page pointer returned by the corresponding {@code 
acquirePage} call.
+     */
+    public void releasePage(int groupId, long pageId, long page);
+
+    /**
+     * Acquires a read lock on the page.

Review comment:
       ```suggestion
        * Acquires a read lock associated with the given page.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId    Group ID.
+     * @param pageId     Page ID.
+     * @param statHolder Statistics holder to track IO operations.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId, IoStatisticsHolder 
statHolder) throws IgniteInternalCheckedException;
+
+    /**
+     * Releases page acquired by one of {@code acquirePage} methods.

Review comment:
       ```suggestion
        * Releases pages acquired by any of the {@code acquirePage} methods.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId    Group ID.
+     * @param pageId     Page ID.
+     * @param statHolder Statistics holder to track IO operations.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId, IoStatisticsHolder 
statHolder) throws IgniteInternalCheckedException;
+
+    /**
+     * Releases page acquired by one of {@code acquirePage} methods.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID to release.
+     * @param page    Page pointer returned by the corresponding {@code 
acquirePage} call.
+     */
+    public void releasePage(int groupId, long pageId, long page);

Review comment:
       I guess the last parameter should be changed to `pageAddr`. Also, why 
don't we accept a `FullPageId` here as well?

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId    Group ID.
+     * @param pageId     Page ID.
+     * @param statHolder Statistics holder to track IO operations.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId, IoStatisticsHolder 
statHolder) throws IgniteInternalCheckedException;
+
+    /**
+     * Releases page acquired by one of {@code acquirePage} methods.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID to release.
+     * @param page    Page pointer returned by the corresponding {@code 
acquirePage} call.
+     */
+    public void releasePage(int groupId, long pageId, long page);
+
+    /**
+     * Acquires a read lock on the page.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @param page    Page pointer.
+     * @return Pointer for reading the page or {@code 0} if page has been 
reused.
+     */
+    public long readLock(int groupId, long pageId, long page);
+
+    /**
+     * Obtains read lock without checking page tag.

Review comment:
       ```suggestion
        * Acquires a read lock, associated with a given page, without checking 
the page tag.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId    Group ID.
+     * @param pageId     Page ID.
+     * @param statHolder Statistics holder to track IO operations.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId, IoStatisticsHolder 
statHolder) throws IgniteInternalCheckedException;
+
+    /**
+     * Releases page acquired by one of {@code acquirePage} methods.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID to release.
+     * @param page    Page pointer returned by the corresponding {@code 
acquirePage} call.
+     */
+    public void releasePage(int groupId, long pageId, long page);
+
+    /**
+     * Acquires a read lock on the page.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @param page    Page pointer.
+     * @return Pointer for reading the page or {@code 0} if page has been 
reused.
+     */
+    public long readLock(int groupId, long pageId, long page);
+
+    /**
+     * Obtains read lock without checking page tag.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @param page    Page pointer.
+     * @return Pointer for reading the page.
+     */
+    public long readLockForce(int groupId, long pageId, long page);
+
+    /**
+     * Releases locked page.

Review comment:
       ```suggestion
        * Releases a read lock, associated with a given page.
   ```

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId    Group ID.
+     * @param pageId     Page ID.
+     * @param statHolder Statistics holder to track IO operations.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId, IoStatisticsHolder 
statHolder) throws IgniteInternalCheckedException;
+
+    /**
+     * Releases page acquired by one of {@code acquirePage} methods.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID to release.
+     * @param page    Page pointer returned by the corresponding {@code 
acquirePage} call.
+     */
+    public void releasePage(int groupId, long pageId, long page);
+
+    /**
+     * Acquires a read lock on the page.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @param page    Page pointer.
+     * @return Pointer for reading the page or {@code 0} if page has been 
reused.
+     */
+    public long readLock(int groupId, long pageId, long page);
+
+    /**
+     * Obtains read lock without checking page tag.

Review comment:
       Why does this method accepts a `long page` parameter and then returns 
another `long`? What is the difference? `Pointer for reading the page` doesn't 
help with understanding this.

##########
File path: 
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/PageSupport.java
##########
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolder;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+
+/**
+ * Supports operations on pages.
+ */
+public interface PageSupport {
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId) throws 
IgniteInternalCheckedException;
+
+    /**
+     * Returns the page absolute pointer associated with the given page ID. 
Each page obtained with this method must be released by calling
+     * {@link #releasePage(int, long, long)}. This method will allocate page 
with given ID if it doesn't exist.
+     *
+     * @param groupId    Group ID.
+     * @param pageId     Page ID.
+     * @param statHolder Statistics holder to track IO operations.
+     * @return Page pointer.
+     * @throws IgniteInternalCheckedException If failed.
+     */
+    public long acquirePage(int groupId, long pageId, IoStatisticsHolder 
statHolder) throws IgniteInternalCheckedException;
+
+    /**
+     * Releases page acquired by one of {@code acquirePage} methods.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID to release.
+     * @param page    Page pointer returned by the corresponding {@code 
acquirePage} call.
+     */
+    public void releasePage(int groupId, long pageId, long page);
+
+    /**
+     * Acquires a read lock on the page.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @param page    Page pointer.
+     * @return Pointer for reading the page or {@code 0} if page has been 
reused.
+     */
+    public long readLock(int groupId, long pageId, long page);
+
+    /**
+     * Obtains read lock without checking page tag.
+     *
+     * @param groupId Group ID.
+     * @param pageId  Page ID.
+     * @param page    Page pointer.
+     * @return Pointer for reading the page.
+     */
+    public long readLockForce(int groupId, long pageId, long page);
+
+    /**
+     * Releases locked page.

Review comment:
       What will happen if I will try to release a page that had not been 
locked?




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