org.apache.ignite.internal.processors.cache.persistence.pagemem

## Interface PageMemoryEx

All Superinterfaces:
  PageIdAllocator, PageMemory, PageSupport

All Known Implementing Classes:
  PageMemoryImpl

    public interface PageMemoryEx
    extends PageMemory

### Field Summary

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

`FLAG_DATA, FLAG_IDX, INDEX_PARTITION, MAX_PARTITION_ID`

### Method Summary

All Methods Instance Methods Abstract Methods
`long` `acquirePage(int grpId, long pageId, boolean restore)`
`GridMultiCollectionWrapper<FullPageId>` `beginCheckpoint()` Gets a collection of dirty page IDs since the last checkpoint.
`IgniteInternalFuture<Void>` `clearAsync(LoadedPagesMap.KeyPredicate pred, boolean cleanDirty)` Asynchronously clears pages satisfying the given predicate.
`void` `finishCheckpoint()` Finishes checkpoint operation.
`Integer` `getForCheckpoint(FullPageId pageId, ByteBuffer outBuf, CheckpointMetricsTracker tracker)` Gets page byte buffer for the checkpoint procedure.
`int` `invalidate(int grpId, int partId)` Marks partition as invalid / outdated.
`long` `metaPageId(int grpId)` Gets or allocates metadata page for specified grpId.
`void` `onCacheGroupDestroyed(int grpId)` Clears internal metadata of destroyed cache group.
`long` `partitionMetaPageId(int grpId, int partId)` Gets or allocates partition metadata page for specified grpId and partId.
`boolean` `safeToUpdate()` Heuristic method which allows a thread to check if it safe to start memory struture modifications in regard with checkpointing.
`long` `writeLock(int grpId, long pageId, long page, boolean restore)`
`void` `writeUnlock(int grpId, long pageId, long page, Boolean walPlc, boolean dirtyFlag, boolean restore)`

### Methods inherited from interface org.apache.ignite.internal.pagemem.PageMemory

`checkpointBufferPagesCount, loadedPages, pageBuffer, pageSize, realPageSize, start, stop, systemPageSize`

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

`allocatePage, freePage`

### Methods inherited from interface org.apache.ignite.internal.pagemem.PageSupport

`acquirePage, isDirty, readLock, readLockForce, readUnlock, releasePage, tryWriteLock, writeLock, writeUnlock`

### Method Detail

#### writeLock

    long writeLock(int grpId,
                   long pageId,
                   long page,
                   boolean restore)

Parameters:
  `grpId` - Group ID.
  `pageId` - Page ID.
  `page` - Page pointer.
  `restore` - Determines if the page is locked for restore.
Returns:
  ByteBuffer for modifying the page.

#### writeUnlock

    void writeUnlock(int grpId,
                     long pageId,
                     long page,
                     Boolean walPlc,
                     boolean dirtyFlag,
                     boolean restore)

Parameters:
  `grpId` - Group 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.
  `restore` - Determines if the page is locked for restore.

#### metaPageId

    long metaPageId(int grpId)
             throws IgniteCheckedException

Gets or allocates metadata page for specified grpId.

Parameters:
  `grpId` - Group ID.
Returns:
  Meta page for grpId.
Throws:
  `IgniteCheckedException` - If failed.

#### partitionMetaPageId

    long partitionMetaPageId(int grpId,
                             int partId)
                      throws IgniteCheckedException

Gets or allocates partition metadata page for specified grpId and partId.

Parameters:
  `grpId` - Group ID.
  `partId` - Partition ID.
Returns:
  Meta page for grpId and partId.
Throws:
  `IgniteCheckedException` - If failed.

#### acquirePage

    long acquirePage(int grpId,
                     long pageId,
                     boolean restore)
              throws IgniteCheckedException

Parameters:
  `grpId` - Cache group ID.
  `pageId` - Page id.
  `restore` - Get page for restore
Returns:
  Page.
Throws:
  `IgniteCheckedException` - If failed.
  `StorageException` - If page reading failed from storage.
See Also:
  `Will not read page from file if it is not present in memory`

#### safeToUpdate

    boolean safeToUpdate()

Heuristic method which allows a thread to check if it safe to start memory struture modifications in regard with checkpointing.

Returns:
  `False` if there are too many dirty pages and a thread should wait for a checkpoint to begin.

#### beginCheckpoint

    GridMultiCollectionWrapper<FullPageId> beginCheckpoint()
                                                    throws IgniteException

Gets a collection of dirty page IDs since the last checkpoint. If a dirty page is being written after the checkpointing operation begun, the modifications will be written to a temporary buffer which will be flushed to the main memory after the checkpointing finished. This method must be called when no concurrent operations on pages are performed.

Returns:
  Collection of dirty page IDs.
Throws:
  `IgniteException` - If checkpoint has been already started and was not finished.

#### finishCheckpoint

    void finishCheckpoint()

Finishes checkpoint operation.

#### getForCheckpoint

    @Nullable
    Integer getForCheckpoint(FullPageId pageId,
                                       ByteBuffer outBuf,
                                       CheckpointMetricsTracker tracker)

Gets page byte buffer for the checkpoint procedure.

Parameters:
  `pageId` - Page ID to get byte buffer for. The page ID must be present in the collection returned by the `beginCheckpoint()` method call.
  `outBuf` - Temporary buffer to write changes into.
  `tracker` - Checkpoint metrics tracker.
Returns:
  `Partition generation` if data was read, `null` otherwise (data already saved to storage).
Throws:
  `IgniteException` - If failed to obtain page data.

#### invalidate

    int invalidate(int grpId,
                   int partId)

Marks partition as invalid / outdated.

Parameters:
  `grpId` - Group ID.
  `partId` - Partition ID.
Returns:
  New partition generation (growing 1-based partition file version).

#### onCacheGroupDestroyed

    void onCacheGroupDestroyed(int grpId)

Clears internal metadata of destroyed cache group.

Parameters:
  `grpId` - Cache group ID.

#### clearAsync

    IgniteInternalFuture<Void> clearAsync(LoadedPagesMap.KeyPredicate pred,
                                          boolean cleanDirty)

Asynchronously clears pages satisfying the given predicate.

Parameters:
  `pred` - Predicate for cache group id, pageId.
  `cleanDirty` - Flag indicating that dirty pages collection should be cleaned.
Returns:
  Future that will be completed when all pages are cleared.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.5
Release Date | : June 4 2019