Class AbstractFreeList<T extends Storable>
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.persistence.DataStructure
-
- org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList
-
- org.apache.ignite.internal.processors.cache.persistence.freelist.AbstractFreeList<T>
-
- Direct Known Subclasses:
CacheFreeList,PartitionMetaStorageImpl
public abstract class AbstractFreeList<T extends Storable> extends PagesList implements FreeList<T>, ReuseList
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList
PagesList.PagesCache, PagesList.Stripe
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList
bucketsSize, changed, DFLT_PAGES_LIST_TRY_LOCK_ATTEMPTS, IGNITE_PAGES_LIST_STRIPES_PER_BUCKET, IGNITE_PAGES_LIST_TRY_LOCK_ATTEMPTS, log, pageCacheChanged
-
Fields inherited from class org.apache.ignite.internal.processors.cache.persistence.DataStructure
grpId, grpName, metrics, pageFlag, pageIoRslvr, pageMem, reuseList, rnd, wal
-
-
Constructor Summary
Constructors Constructor Description AbstractFreeList(int cacheGrpId, String name, DataRegion dataRegion, @Nullable ReuseList reuseList, @Nullable IgniteWriteAheadLogManager wal, long metaPageId, boolean initNew, PageLockTrackerManager pageLockTrackerManager, GridKernalContext ctx, @Nullable AtomicLong pageListCacheLimit, byte pageFlag)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddForRecycle(ReuseBag bag)protected booleancasBucket(int bucket, PagesList.Stripe[] exp, PagesList.Stripe[] upd)voiddumpStatistics(IgniteLogger log)intemptyDataPages()longfreeSpace()Calculates free space tracked by this FreeListImpl instance.protected PagesList.Stripe[]getBucket(int bucket)protected PagesList.PagesCachegetBucketCache(int bucket, boolean create)protected intgetBucketIndex(int freeSpace)Gets bucket index by page freespace.intgetPageFreeSpace(int bucket)Gets per page free space for specified bucket.longinitRecycledPage(long pageId, byte flag, PageIO initIO)Converts recycled page id back to a usable id.voidinsertDataRow(T row, IoStatisticsHolder statHolder)voidinsertDataRows(Collection<T> rows, IoStatisticsHolder statHolder)Reduces the workload on the free list by writing multiple rows into a single memory page at once.
Rows are sequentially added to the page as long as there is enough free space on it.protected booleanisReuseBucket(int bucket)longrecycledPagesCount()voidremoveDataRowByLink(long link, IoStatisticsHolder statHolder)longtakeRecycledPage()StringtoString()booleanupdateDataRow(long link, T row, IoStatisticsHolder statHolder)-
Methods inherited from class org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList
bucketsCount, bucketSize, cachedPagesCount, corruptedFreeListException, corruptedFreeListException, corruptedFreeListException, init, initRecycledPage0, initReusedPage, metaPageId, put, removeDataPage, saveMetadata, storedPagesCount, stripesCount, takeEmptyPage
-
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
-
-
-
-
Constructor Detail
-
AbstractFreeList
public AbstractFreeList(int cacheGrpId, String name, DataRegion dataRegion, @Nullable @Nullable ReuseList reuseList, @Nullable @Nullable IgniteWriteAheadLogManager wal, long metaPageId, boolean initNew, PageLockTrackerManager pageLockTrackerManager, GridKernalContext ctx, @Nullable @Nullable AtomicLong pageListCacheLimit, byte pageFlag) throws IgniteCheckedException- Parameters:
cacheGrpId- Cache group ID.name- Name (for debug purpose).dataRegion- Data region.reuseList- Reuse list ornullif this free list will be a reuse list for itself.wal- Write ahead log manager.metaPageId- Metadata page ID.initNew-Trueif new metadata should be initialized.pageLockTrackerManager- Page lock tracker manager.pageFlag- Default flag value for allocated pages.- Throws:
IgniteCheckedException- If failed.
-
-
Method Detail
-
getPageFreeSpace
public int getPageFreeSpace(int bucket)
Gets per page free space for specified bucket.- Specified by:
getPageFreeSpacein classPagesList- Returns:
- Free space available to use for each page in specified bucket.
-
freeSpace
public long freeSpace()
Calculates free space tracked by this FreeListImpl instance.- Returns:
- Free space available for use, in bytes.
-
dumpStatistics
public void dumpStatistics(IgniteLogger log)
- Specified by:
dumpStatisticsin interfaceFreeList<T extends Storable>- Parameters:
log- Logger.
-
getBucketIndex
protected int getBucketIndex(int freeSpace)
Gets bucket index by page freespace.- Specified by:
getBucketIndexin classPagesList- Returns:
- Bucket index or -1 if page doesn't belong to any bucket.
-
insertDataRow
public void insertDataRow(T row, IoStatisticsHolder statHolder) throws IgniteCheckedException
- Specified by:
insertDataRowin interfaceFreeList<T extends Storable>- Parameters:
row- Row.statHolder- Statistics holder to track IO operations.- Throws:
IgniteCheckedException- If failed.
-
insertDataRows
public void insertDataRows(Collection<T> rows, IoStatisticsHolder statHolder) throws IgniteCheckedException
Reduces the workload on the free list by writing multiple rows into a single memory page at once.
Rows are sequentially added to the page as long as there is enough free space on it. If the row is large then those fragments that occupy the whole memory page are written to other pages, and the remainder is added to the current one.- Specified by:
insertDataRowsin interfaceFreeList<T extends Storable>- Parameters:
rows- Rows.statHolder- Statistics holder to track IO operations.- Throws:
IgniteCheckedException- If failed.
-
updateDataRow
public boolean updateDataRow(long link, T row, IoStatisticsHolder statHolder) throws IgniteCheckedException- Specified by:
updateDataRowin interfaceFreeList<T extends Storable>- Parameters:
link- Row link.row- New row data.statHolder- Statistics holder to track IO operations.- Returns:
Trueif was able to update row.- Throws:
IgniteCheckedException- If failed.
-
removeDataRowByLink
public void removeDataRowByLink(long link, IoStatisticsHolder statHolder) throws IgniteCheckedException- Specified by:
removeDataRowByLinkin interfaceFreeList<T extends Storable>- Parameters:
link- Row link.statHolder- Statistics holder to track IO operations.- Throws:
IgniteCheckedException- If failed.
-
getBucket
protected PagesList.Stripe[] getBucket(int bucket)
-
casBucket
protected boolean casBucket(int bucket, PagesList.Stripe[] exp, PagesList.Stripe[] upd)
-
isReuseBucket
protected boolean isReuseBucket(int bucket)
- Specified by:
isReuseBucketin classPagesList- Parameters:
bucket- Bucket index.- Returns:
trueIf it is a reuse bucket.
-
getBucketCache
protected PagesList.PagesCache getBucketCache(int bucket, boolean create)
- Specified by:
getBucketCachein classPagesList- Parameters:
bucket- Bucket index.- Returns:
- Bucket cache.
-
emptyDataPages
public int emptyDataPages()
- Returns:
- Number of empty data pages in free list.
-
addForRecycle
public void addForRecycle(ReuseBag bag) throws IgniteCheckedException
- Specified by:
addForRecyclein interfaceReuseList- Parameters:
bag- Reuse bag.- Throws:
IgniteCheckedException- If failed.
-
takeRecycledPage
public long takeRecycledPage() throws IgniteCheckedException- Specified by:
takeRecycledPagein interfaceReuseList- Returns:
- Page ID or
0if none available. - Throws:
IgniteCheckedException- If failed.
-
initRecycledPage
public long initRecycledPage(long pageId, byte flag, PageIO initIO) throws IgniteCheckedExceptionConverts recycled page id back to a usable id. Might modify page content as well if flag is changing.- Specified by:
initRecycledPagein interfaceReuseList- Parameters:
pageId- Id of the recycled page.flag- Flag value for the page. One ofPageIdAllocator.FLAG_DATA,PageIdAllocator.FLAG_IDXorPageIdAllocator.FLAG_AUX.initIO- Page IO to reinit reused page.- Returns:
- Updated page id.
- Throws:
IgniteCheckedException- If failed.- See Also:
FullPageId
-
recycledPagesCount
public long recycledPagesCount() throws IgniteCheckedException- Specified by:
recycledPagesCountin interfaceReuseList- Returns:
- Number of recycled pages it contains.
- Throws:
IgniteCheckedException- If failed.
-
-