Class PagesList
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.persistence.DataStructure
-
- org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList
-
- Direct Known Subclasses:
AbstractFreeList,ReuseListImpl
public abstract class PagesList extends DataStructure
Striped doubly-linked list of page IDs optionally organized in buckets.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPagesList.PagesCacheClass to store page-list cache onheap.static classPagesList.Stripe
-
Field Summary
Fields Modifier and Type Field Description protected AtomicLongArraybucketsSizeprotected booleanchangedstatic intDFLT_PAGES_LIST_TRY_LOCK_ATTEMPTSstatic StringIGNITE_PAGES_LIST_STRIPES_PER_BUCKETstatic StringIGNITE_PAGES_LIST_TRY_LOCK_ATTEMPTSprotected IgniteLoggerlogLogger.protected booleanpageCacheChangedPage cache changed.-
Fields inherited from class org.apache.ignite.internal.processors.cache.persistence.DataStructure
grpId, grpName, metrics, pageFlag, pageIoRslvr, pageMem, reuseList, rnd, wal
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPagesList(int cacheGrpId, String name, PageMemory pageMem, int buckets, @Nullable IgniteWriteAheadLogManager wal, long metaPageId, PageLockTrackerManager pageLockTrackerManager, GridKernalContext ctx, byte pageFlag)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intbucketsCount()Buckets 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, @Nullable 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.abstract intgetPageFreeSpace(int bucket)Gets per page free space for specified bucket.protected 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 longinitReusedPage(long reusedPageId, long reusedPage, long reusedPageAddr, int partId, byte flag, PageIO initIo)Reused page must obtain correctly assaembled page id, then initialized by properPageIOinstance and non-zeroitemIdof reused page id must be saved into special place.protected abstract booleanisReuseBucket(int bucket)longmetaPageId()protected voidput(@Nullable ReuseBag bag, long dataId, long dataPage, long dataAddr, int bucket, IoStatisticsHolder statHolder)protected 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 longstoredPagesCount(int bucket)!!!intstripesCount(int bucket)Stripes count.protected longtakeEmptyPage(int bucket, @Nullable IOVersions initIoVers, IoStatisticsHolder statHolder)-
Methods inherited from class org.apache.ignite.internal.processors.cache.persistence.DataStructure
acquirePage, allocatePage, allocatePage, allocatePageNoReuse, close, groupId, init, name, needWalDeltaRecord, pageSize, randomInt, read, read, readLock, readUnlock, recyclePage, releasePage, tryWriteLock, write, write, write, write, writeLock, writeUnlock, writeUnlock
-
-
-
-
Field Detail
-
DFLT_PAGES_LIST_TRY_LOCK_ATTEMPTS
public static final int DFLT_PAGES_LIST_TRY_LOCK_ATTEMPTS
-
IGNITE_PAGES_LIST_STRIPES_PER_BUCKET
@SystemProperty(value="Maximum count of the stripes", type=java.lang.Long.class, defaults="Maximum of 8 and available processors count") public static final String IGNITE_PAGES_LIST_STRIPES_PER_BUCKET
- See Also:
- Constant Field Values
-
IGNITE_PAGES_LIST_TRY_LOCK_ATTEMPTS
@SystemProperty(value="Count of tries to lock stripe before fail back to blocking lock", type=java.lang.Long.class, defaults="10") public static final String IGNITE_PAGES_LIST_TRY_LOCK_ATTEMPTS
- See Also:
- Constant Field Values
-
bucketsSize
protected final AtomicLongArray bucketsSize
-
changed
protected volatile boolean changed
-
pageCacheChanged
protected volatile boolean pageCacheChanged
Page cache changed.
-
log
protected final IgniteLogger log
Logger.
-
-
Constructor Detail
-
PagesList
protected PagesList(int cacheGrpId, String name, PageMemory pageMem, int buckets, @Nullable @Nullable IgniteWriteAheadLogManager wal, long metaPageId, PageLockTrackerManager pageLockTrackerManager, GridKernalContext ctx, byte pageFlag)- Parameters:
cacheGrpId- Cache group ID.name- Name (for debug purpose).pageMem- Page memory.buckets- Number of buckets.metaPageId- Metadata page ID.pageFlag- Default flag value for allocated pages.
-
-
Method Detail
-
init
protected final void init(long metaPageId, boolean initNew) throws IgniteCheckedException- Parameters:
metaPageId- Metadata page ID.initNew-Trueif new list if created,falseif should be initialized from metadata.- Throws:
IgniteCheckedException- If failed.
-
saveMetadata
public void saveMetadata(IoStatisticsHolder statHolder) throws IgniteCheckedException
Save metadata without exclusive lock on it.- Throws:
IgniteCheckedException- If failed.
-
getPageFreeSpace
public abstract int getPageFreeSpace(int bucket)
Gets per page free space for specified bucket.- Returns:
- Free space available to use for each page in specified bucket.
-
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
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:
trueIf succeeded.
-
isReuseBucket
protected abstract boolean isReuseBucket(int bucket)
- Parameters:
bucket- Bucket index.- Returns:
trueIf it is a reuse bucket.
-
getBucketCache
protected abstract PagesList.PagesCache getBucketCache(int bucket, boolean create)
- Parameters:
bucket- Bucket index.- Returns:
- Bucket cache.
-
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(@Nullable @Nullable 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, @Nullable @Nullable 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 IgniteCheckedExceptionCreate 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:
initReusedPage(long, long, long, int, byte, PageIO)
-
initReusedPage
protected final long initReusedPage(long reusedPageId, long reusedPage, long reusedPageAddr, int partId, byte flag, PageIO initIo) throws IgniteCheckedExceptionReused page must obtain correctly assaembled 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 IgniteCheckedExceptionRemoves 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.
-
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.
-
metaPageId
public long metaPageId()
- Returns:
- Meta page id.
-
corruptedFreeListException
protected CorruptedFreeListException corruptedFreeListException(Throwable err, long... pageIds)
- 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
protected CorruptedFreeListException corruptedFreeListException(String msg, long... pageIds)
- 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, @Nullable @Nullable 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.
-
-