org.apache.ignite.internal.pagemem.impl

## Class PageMemoryNoStoreImpl

- java.lang.Object
- - org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl

All Implemented Interfaces:
  PageIdAllocator, PageMemory, PageSupport, LifecycleAware

    public class PageMemoryNoStoreImpl
    extends Object
    implements PageMemory

Page header structure is described by the following diagram. When page is not allocated (in a free list):

     +--------+--------+---------------------------------------------+
     |8 bytes |8 bytes |     PAGE_SIZE + PAGE_OVERHEAD - 16 bytes    |
     +--------+--------+---------------------------------------------+
     |Next ptr|Rel ptr |              Empty                          |
     +--------+--------+---------------------------------------------+

When page is allocated and is in use:

     +--------+--------+--------+--------+---------------------------+
     |8 bytes |8 bytes |8 bytes |8 bytes |        PAGE_SIZE          |
     +--------+--------+--------+--------+---------------------------+
     | Marker |Page ID |Pin CNT |  Lock  |        Page data          |
     +--------+--------+--------+--------+---------------------------+

Note that first 8 bytes of page header are used either for page marker or for next relative pointer depending on whether the page is in use or not.

### Field Summary

Fields
`static int` `LOCK_OFFSET` Page pin counter offset.
`static int` `PAGE_ID_OFFSET` Page ID offset.
`static long` `PAGE_MARKER`
`static int` `PAGE_OVERHEAD` Need a 8-byte pointer for linked list, 8 bytes for internal needs (flags), 4 bytes cache ID, 8 bytes timestamp.

### Fields inherited from interface org.apache.ignite.internal.pagemem.PageIdAllocator

`FLAG_DATA, FLAG_IDX, INDEX_PARTITION, MAX_PARTITION_ID`

### Constructor Summary

Constructors
Constructor and Description
`PageMemoryNoStoreImpl(IgniteLogger log, DirectMemoryProvider directMemoryProvider, GridCacheSharedContext<?,?> sharedCtx, int pageSize, MemoryPolicyConfiguration memPlcCfg, MemoryMetricsImpl memMetrics, boolean trackAcquiredPages)`

### Method Summary

Methods
`long` `acquiredPages()`
`long` `acquirePage(int cacheId, long pageId)` Gets the page absolute pointer associated with the given page ID.
`long` `allocatePage(int cacheId, int partId, byte flags)` Allocates a page from the space for the given partition ID and the given flags.
`boolean` `freePage(int cacheId, long pageId)` The given page is free now.
`boolean` `isDirty(int cacheId, long pageId, long page)`
`long` `loadedPages()`
`ByteBuffer` `pageBuffer(long pageAddr)`
`int` `pageIndex(int seqNo)`
`int` `pageSequenceNumber(int pageIdx)`
`int` `pageSize()`
`long` `readLock(int cacheId, long pageId, long page)`
`long` `readLockForce(int cacheId, long pageId, long page)` Obtains read lock without checking page tag.
`void` `readUnlock(int cacheId, long pageId, long page)` Releases locked page.
`void` `releasePage(int cacheId, long pageId, long page)`
`void` `start()` Starts grid component, called on grid start.
`void` `stop()` Stops grid component, called on grid shutdown.
`int` `systemPageSize()`
`int` `totalPages()`
`long` `tryWriteLock(int cacheId, long pageId, long page)`
`long` `writeLock(int cacheId, long pageId, long page)`
`void` `writeUnlock(int cacheId, long pageId, long page, Boolean walPlc, boolean dirtyFlag)` Releases locked page.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### PAGE_MARKER

    public static final long PAGE_MARKER

See Also:
  Constant Field Values

#### PAGE_ID_OFFSET

    public static final int PAGE_ID_OFFSET

Page ID offset.

See Also:
  Constant Field Values

#### LOCK_OFFSET

    public static final int LOCK_OFFSET

Page pin counter offset.

See Also:
  Constant Field Values

#### PAGE_OVERHEAD

    public static final int PAGE_OVERHEAD

Need a 8-byte pointer for linked list, 8 bytes for internal needs (flags), 4 bytes cache ID, 8 bytes timestamp.

See Also:
  Constant Field Values

### Constructor Detail

#### PageMemoryNoStoreImpl

    public PageMemoryNoStoreImpl(IgniteLogger log,
                         DirectMemoryProvider directMemoryProvider,
                         GridCacheSharedContext<?,?> sharedCtx,
                         int pageSize,
                         MemoryPolicyConfiguration memPlcCfg,
                         MemoryMetricsImpl memMetrics,
                         boolean trackAcquiredPages)

Parameters:
  `log` - Logger.
  `directMemoryProvider` - Memory allocator to use.
  `sharedCtx` - Cache shared context.
  `pageSize` - Page size.
  `memPlcCfg` - Memory Policy configuration.
  `memMetrics` - Memory Metrics.
  `trackAcquiredPages` - If `true` tracks number of allocated pages (for tests purpose only).

### Method Detail

#### start

    public void start()
               throws IgniteException

Starts grid component, called on grid start.

Specified by:
  `start` in interface `LifecycleAware`
Throws:
  `IgniteException` - If failed.

#### stop

    public void stop()
              throws IgniteException

Stops grid component, called on grid shutdown.

Specified by:
  `stop` in interface `LifecycleAware`
Throws:
  `IgniteException` - If failed.

#### pageBuffer

    public ByteBuffer pageBuffer(long pageAddr)

Specified by:
  `pageBuffer` in interface `PageMemory`
Parameters:
  `pageAddr` - Page address.
Returns:
  Page byte buffer.

#### allocatePage

    public long allocatePage(int cacheId,
                    int partId,
                    byte flags)

Allocates a page from the space for the given partition ID and the given flags.

Specified by:
  `allocatePage` in interface `PageIdAllocator`
  `partId` - Partition ID.
Returns:
  Allocated page ID.

#### freePage

    public boolean freePage(int cacheId,
                   long pageId)

The given page is free now.

Specified by:
  `freePage` in interface `PageIdAllocator`
Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.

#### pageSize

    public int pageSize()

Specified by:
  `pageSize` in interface `PageMemory`
Returns:
  Page size in bytes.

#### systemPageSize

    public int systemPageSize()

Specified by:
  `systemPageSize` in interface `PageMemory`
Returns:
  Page size with system overhead, in bytes.

#### loadedPages

    public long loadedPages()

Specified by:
  `loadedPages` in interface `PageMemory`
Returns:
  Total number of loaded pages in memory.

#### totalPages

    public int totalPages()

Returns:
  Total number of pages may be allocated for this instance.

#### acquiredPages

    public long acquiredPages()

Returns:
  Total number of acquired pages.

#### acquirePage

    public long acquirePage(int cacheId,
                   long pageId)

Gets the page absolute pointer associated with the given page ID. Each page obtained with this method must be released by calling `PageSupport.releasePage(int, long, long)`. This method will allocate page with given ID if it doesn't exist.

Specified by:
  `acquirePage` in interface `PageSupport`
Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.
Returns:
  Page pointer.

#### releasePage

    public void releasePage(int cacheId,
                   long pageId,
                   long page)

Specified by:
  `releasePage` in interface `PageSupport`
Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID to release.
  `page` - Page pointer.

#### readLock

    public long readLock(int cacheId,
                long pageId,
                long page)

Specified by:
  `readLock` in interface `PageSupport`
Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
Returns:
  Pointer for reading the page.

#### readLockForce

    public long readLockForce(int cacheId,
                     long pageId,
                     long page)

Obtains read lock without checking page tag.

Specified by:
  `readLockForce` in interface `PageSupport`
Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
Returns:
  Pointer for reading the page.

#### readUnlock

    public void readUnlock(int cacheId,
                  long pageId,
                  long page)

Releases locked page.

Specified by:
  `readUnlock` in interface `PageSupport`
Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.

#### writeLock

    public long writeLock(int cacheId,
                 long pageId,
                 long page)

Specified by:
  `writeLock` in interface `PageSupport`
Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
Returns:
  Address of a buffer with contents of the given page or `0L` if attempt to take the write lock failed.

#### tryWriteLock

    public long tryWriteLock(int cacheId,
                    long pageId,
                    long page)

Specified by:
  `tryWriteLock` in interface `PageSupport`
Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
Returns:
  Address of a buffer with contents of the given page or `0L` if attempt to take the write lock failed.

#### writeUnlock

    public void writeUnlock(int cacheId,
                   long pageId,
                   long page,
                   Boolean walPlc,
                   boolean dirtyFlag)

Releases locked page.

Specified by:
  `writeUnlock` in interface `PageSupport`
Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
  `walPlc` - `True` if page should be recorded to WAL, `false` if the page must not be recorded and `null` for the default behavior.
  `dirtyFlag` - Determines whether the page was modified since the last checkpoint.

#### isDirty

    public boolean isDirty(int cacheId,
                  long pageId,
                  long page)

Specified by:
  `isDirty` in interface `PageSupport`
Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
Returns:
  `True` if the page is dirty.

#### pageSequenceNumber

    public int pageSequenceNumber(int pageIdx)

Parameters:
  `pageIdx` - Page index.
Returns:
  Total page sequence number.

#### pageIndex

    public int pageIndex(int seqNo)

Parameters:
  `seqNo` - Page sequence number.
Returns:
  Page index.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.0.0
Release Date | : April 30 2017