Class PagesList
java.lang.Object
org.apache.ignite.internal.DataStructure
org.apache.ignite.internal.persistence.freelist.PagesList
- All Implemented Interfaces:
MetaStorage
- Direct Known Subclasses:
FreeListImpl,ReuseListImpl
public abstract class PagesList
extends org.apache.ignite.internal.DataStructure
implements MetaStorage
Striped doubly-linked list of page IDs optionally organized in buckets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass to store page-list cache onheap.static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicLongArrayprotected booleanprotected final IgniteLoggerLogger.protected final StringName (for debug purposes).protected booleanPage cache changed.Fields inherited from class org.apache.ignite.internal.DataStructure
grpId, grpName, lockLsnr, pageAccessHelper, pageFlag, pageMem, reuseList, rnd, wal -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPagesList(int cacheId, String name, PageMemory pageMem, int buckets, int pageSize, WalManager wal, org.apache.ignite.internal.PageAccessHelper pageHandler, long metaPageId, PageLockListener lockLsnr, IgniteLogger log, byte pageFlag) -
Method Summary
Modifier and TypeMethodDescriptionintBuckets count.longbucketSize(int bucket) Bucket size.intcachedPagesCount(int bucket) Cached pages count.protected abstract booleancasBucket(int bucket, PagesList.Stripe[] exp, PagesList.Stripe[] upd) protected CorruptedFreeListExceptioncorruptedFreeListException(String msg, long... pageIds) protected CorruptedFreeListExceptioncorruptedFreeListException(String msg, Throwable err, long... pageIds) protected CorruptedFreeListExceptioncorruptedFreeListException(Throwable err, long... pageIds) protected abstract PagesList.Stripe[]getBucket(int bucket) protected abstract PagesList.PagesCachegetBucketCache(int bucket, boolean create) protected abstract intgetBucketIndex(int freeSpace) Gets bucket index by page freespace.protected final voidinit(long metaPageId, boolean initNew) protected longinitRecycledPage0(long pageId, byte flag, PageIO initIO) Create new page id and update page content accordingly if it's necessary.protected final longinitReusedPage(long reusedPageId, long reusedPage, long reusedPageAddr, byte flag, PageIO initIo) Reused page must obtain correctly assembled page id, then initialized by properPageIOinstance and non-zeroitemIdof reused page id must be saved into special place.protected abstract booleanisReuseBucket(int bucket) name()Pages list name.protected final voidput(ReuseBag bag, long dataId, long dataPage, long dataAddr, int bucket, IoStatisticsHolder statHolder) protected final booleanremoveDataPage(long dataId, long dataPage, long dataAddr, AbstractDataPageIO dataIO, int bucket, IoStatisticsHolder statHolder) Removes data page from bucket, merges bucket list if needed.voidsaveMetadata(IoStatisticsHolder statHolder) Save metadata without exclusive lock on it.protected final longstoredPagesCount(int bucket) !!!intstripesCount(int bucket) Stripes count.protected longtakeEmptyPage(int bucket, IOVersions initIoVers, IoStatisticsHolder statHolder) Methods inherited from class org.apache.ignite.internal.DataStructure
acquireAndWrite, acquirePage, allocatePage, allocatePage, allocatePageNoReuse, close, groupId, init, needWalDeltaRecord, randomInt, read, read, readLock, readUnlock, recyclePage, releasePage, tryWriteLock, tryWriteLock, write, write, write, writeLock, writeLock, writeUnlock, writeUnlock
-
Field Details
-
bucketsSize
-
changed
protected volatile boolean changed -
pageCacheChanged
protected volatile boolean pageCacheChangedPage cache changed. -
name
Name (for debug purposes). -
log
Logger.
-
-
Constructor Details
-
PagesList
protected PagesList(int cacheId, String name, PageMemory pageMem, int buckets, int pageSize, WalManager wal, org.apache.ignite.internal.PageAccessHelper pageHandler, long metaPageId, PageLockListener lockLsnr, IgniteLogger log, byte pageFlag) - Parameters:
cacheId- Cache ID.name- Name (for debug purpose).pageMem- Page memory.buckets- Number of buckets.pageSize- Page size.wal- Write ahead log manager.pageHandler- Page access helper.metaPageId- Metadata page ID.lockLsnr- Page lock listener.log- Log.pageFlag- Default flag value for allocated pages.
-
-
Method Details
-
init
- Parameters:
metaPageId- Metadata page ID.initNew-Trueif new list if created,falseif should be initialized from metadata.- Throws:
IgniteCheckedException- If failed.
-
saveMetadata
Save metadata without exclusive lock on it.- Specified by:
saveMetadatain interfaceMetaStorage- Throws:
IgniteCheckedException- If failed.
-
getBucketIndex
protected abstract int getBucketIndex(int freeSpace) Gets bucket index by page freespace.- Returns:
- Bucket index or -1 if page doesn't belong to any bucket.
-
getBucket
- Parameters:
bucket- Bucket index.- Returns:
- Bucket.
-
casBucket
- Parameters:
bucket- Bucket index.exp- Expected bucket.upd- Updated bucket.- Returns:
trueIf succeeded.
-
isReuseBucket
protected abstract boolean isReuseBucket(int bucket) - Parameters:
bucket- Bucket index.- Returns:
trueIf it is a reuse bucket.
-
getBucketCache
- Parameters:
bucket- Bucket index.- Returns:
- Bucket cache.
-
storedPagesCount
!!! 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, IoStatisticsHolder statHolder) throws IgniteCheckedException - Parameters:
bag- Reuse bag.dataId- Data page ID.dataPage- Data page pointer.dataAddr- Data page address.bucket- Bucket.statHolder- Statistics holder to track IO operations.- Throws:
IgniteCheckedException- If failed.
-
takeEmptyPage
protected long takeEmptyPage(int bucket, IOVersions initIoVers, IoStatisticsHolder statHolder) throws IgniteCheckedException - Parameters:
bucket- Bucket index.initIoVers- Optional IO to initialize page.statHolder- Statistics holder to track IO operations.- Returns:
- Removed page ID.
- Throws:
IgniteCheckedException- If failed.
-
initRecycledPage0
protected long initRecycledPage0(long pageId, byte flag, PageIO initIO) throws IgniteCheckedException Create new page id and update page content accordingly if it's necessary.- Parameters:
pageId- Id of the recycled page from reuse bucket.flag- New flag for the page.- Returns:
- New page id.
- Throws:
IgniteCheckedException- If failed.- See Also:
-
PagesList#initReusedPage(long, long, long, int, byte, PageIO)
-
initReusedPage
protected final long initReusedPage(long reusedPageId, long reusedPage, long reusedPageAddr, byte flag, PageIO initIo) throws IgniteCheckedException Reused page must obtain correctly assembled page id, then initialized by properPageIOinstance and non-zeroitemIdof reused page id must be saved into special place.- Parameters:
reusedPageId- Reused page id.reusedPage- Reused page.reusedPageAddr- Reused page address.partId- Partition id.flag- Flag.initIo- Initial io.- Returns:
- Prepared page id.
- Throws:
IgniteCheckedException- In case of failure.
-
removeDataPage
protected final boolean removeDataPage(long dataId, long dataPage, long dataAddr, AbstractDataPageIO dataIO, int bucket, IoStatisticsHolder statHolder) throws IgniteCheckedException Removes data page from bucket, merges bucket list if needed.- Parameters:
dataId- Data page ID.dataPage- Data page pointer.dataAddr- Data page address.dataIO- Data page IO.bucket- Bucket index.statHolder- Statistics holder to track IO operations.- Returns:
Trueif page was removed.- Throws:
IgniteCheckedException- If failed.
-
name
Pages list name. -
bucketsCount
public int bucketsCount()Buckets count. -
bucketSize
public long bucketSize(int bucket) Bucket size.- Parameters:
bucket- Bucket.
-
stripesCount
public int stripesCount(int bucket) Stripes count.- Parameters:
bucket- Bucket.
-
cachedPagesCount
public int cachedPagesCount(int bucket) Cached pages count.- Parameters:
bucket- Bucket.
-
corruptedFreeListException
- Parameters:
err- Error that caused this exception.pageIds- Ids of possibly corrupted pages.- Returns:
- Exception of type
CorruptedFreeListExceptionthat wraps original error and ids of possibly corrupted pages.
-
corruptedFreeListException
- Parameters:
msg- Exception message.pageIds- Ids of possibly corrupted pages.- Returns:
- Exception of type
CorruptedFreeListExceptionthat wraps original error and ids of possibly corrupted pages.
-
corruptedFreeListException
protected CorruptedFreeListException corruptedFreeListException(String msg, Throwable err, long... pageIds) - Parameters:
msg- Exception message.err- Error that caused this exception.pageIds- Ids of possibly corrupted pages.- Returns:
- Exception of type
CorruptedFreeListExceptionthat wraps original error and ids of possibly corrupted pages.
-