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

## Class PagesList

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.persistence.DataStructure
  - - org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList

All Implemented Interfaces:
  PageLockListener

Direct Known Subclasses:
  FreeListImpl, ReuseListImpl

    public abstract class PagesList
    extends DataStructure

Striped doubly-linked list of page IDs optionally organized in buckets.

### Nested Class Summary

Nested Classes
`static class` `PagesList.Stripe`

### Field Summary

Fields
`protected AtomicLong[]` `bucketsSize`
`protected boolean` `changed`
`protected String` `name` Name (for debug purposes).

### Fields inherited from class org.apache.ignite.internal.processors.cache.persistence.DataStructure

`grpId, pageMem, reuseList, rnd, wal`

### Constructor Summary

Constructors
`protected` `PagesList(int cacheId, String name, PageMemory pageMem, int buckets, IgniteWriteAheadLogManager wal, long metaPageId)`

### Method Summary

Methods
`protected abstract boolean` `casBucket(int bucket, PagesList.Stripe[] exp, PagesList.Stripe[] upd)`
`protected abstract PagesList.Stripe[]` `getBucket(int bucket)`
`protected void` `init(long metaPageId, boolean initNew)`
`protected abstract boolean` `isReuseBucket(int bucket)`
`protected void` `put(ReuseBag bag, long dataId, long dataPage, long dataAddr, int bucket)`
`protected boolean` `removeDataPage(long dataId, long dataPage, long dataAddr, DataPageIO dataIO, int bucket)`
`void` `saveMetadata()`
`protected long` `storedPagesCount(int bucket)` !!!
`protected long` `takeEmptyPage(int bucket, IOVersions initIoVers)`

### Methods inherited from class org.apache.ignite.internal.processors.cache.persistence.DataStructure

`acquirePage, allocatePage, allocatePageNoReuse, groupId, init, needWalDeltaRecord, onBeforeReadLock, onBeforeWriteLock, onReadLock, onReadUnlock, onWriteLock, onWriteUnlock, pageSize, randomInt, read, read, readLock, readUnlock, recyclePage, releasePage, tryWriteLock, write, write, write, write, writeLock, writeUnlock, writeUnlock`

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

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

### Field Detail

#### bucketsSize

    protected final AtomicLong[] bucketsSize

#### changed

    protected volatile boolean changed

#### name

    protected final String name

Name (for debug purposes).

### Constructor Detail

#### PagesList

    protected PagesList(int cacheId,
             String name,
             PageMemory pageMem,
             int buckets,
             IgniteWriteAheadLogManager wal,
             long metaPageId)

Parameters:
  `cacheId` - Cache ID.
  `name` - Name (for debug purpose).
  `pageMem` - Page memory.
  `buckets` - Number of buckets.
  `wal` - Write ahead log manager.
  `metaPageId` - Metadata page ID.

### Method Detail

#### init

    protected final void init(long metaPageId,
            boolean initNew)
                       throws IgniteCheckedException

Parameters:
  `metaPageId` - Metadata page ID.
  `initNew` - `True` if new list if created, `false` if should be initialized from metadata.
Throws:
  `IgniteCheckedException` - If failed.

#### saveMetadata

    public void saveMetadata()
                      throws IgniteCheckedException

Throws:
  `IgniteCheckedException` - If failed.

#### getBucket

    protected abstract PagesList.Stripe[] getBucket(int bucket)

Parameters:
  `bucket` - Bucket index.
Returns:
  Bucket.

#### casBucket

    protected abstract boolean casBucket(int bucket,
                    PagesList.Stripe[] exp,
                    PagesList.Stripe[] upd)

Parameters:
  `bucket` - Bucket index.
  `exp` - Expected bucket.
  `upd` - Updated bucket.
Returns:
  `true` If succeeded.

#### isReuseBucket

    protected abstract boolean isReuseBucket(int bucket)

Parameters:
  `bucket` - Bucket index.
Returns:
  `true` If it is a reuse bucket.

#### storedPagesCount

    protected final long storedPagesCount(int bucket)
                                   throws IgniteCheckedException

!!! For tests only, does not provide any correctness guarantees for concurrent access.

Parameters:
  `bucket` - Bucket index.
Returns:
  Number of pages stored in this list.
Throws:
  `IgniteCheckedException` - If failed.

#### put

    protected final void put(ReuseBag bag,
           long dataId,
           long dataPage,
           long dataAddr,
           int bucket)
                      throws IgniteCheckedException

Parameters:
  `bag` - Reuse bag.
  `dataId` - Data page ID.
  `dataPage` - Data page pointer.
  `dataAddr` - Data page address.
  `bucket` - Bucket.
Throws:
  `IgniteCheckedException` - If failed.

#### takeEmptyPage

    protected final long takeEmptyPage(int bucket,
                     @Nullable
                     IOVersions initIoVers)
                                throws IgniteCheckedException

Parameters:
  `bucket` - Bucket index.
  `initIoVers` - Optional IO to initialize page.
Returns:
  Removed page ID.
Throws:
  `IgniteCheckedException` - If failed.

#### removeDataPage

    protected final boolean removeDataPage(long dataId,
                         long dataPage,
                         long dataAddr,
                         DataPageIO dataIO,
                         int bucket)
                                    throws IgniteCheckedException

Parameters:
  `dataId` - Data page ID.
  `dataPage` - Data page pointer.
  `dataAddr` - Data page address.
  `dataIO` - Data page IO.
  `bucket` - Bucket index.
Returns:
  `True` if page was removed.
Throws:
  `IgniteCheckedException` - If failed.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.1.0
Release Date | : July 20 2017