Class FreeListImpl
java.lang.Object
org.apache.ignite.internal.DataStructure
org.apache.ignite.internal.persistence.freelist.PagesList
org.apache.ignite.internal.persistence.freelist.FreeListImpl
- All Implemented Interfaces:
FreeList,MetaStorage,ReuseList
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.ignite.internal.persistence.freelist.PagesList
PagesList.PagesCache, PagesList.Stripe -
Field Summary
Fields inherited from class org.apache.ignite.internal.persistence.freelist.PagesList
bucketsSize, changed, log, name, pageCacheChangedFields inherited from class org.apache.ignite.internal.DataStructure
grpId, grpName, lockLsnr, pageAccessHelper, pageFlag, pageMem, reuseList, rnd, wal -
Constructor Summary
ConstructorsConstructorDescriptionFreeListImpl(int cacheId, String name, int pageSize, DataRegionMetrics memMetrics, PageMemory pageMemory, ReuseList reuseList, WalManager wal, org.apache.ignite.internal.PageAccessHelper pageHandler, long metaPageId, boolean initNew, PageLockListener lockLsnr, IgniteLogger log, AtomicLong pageListCacheLimit) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddForRecycle(ReuseBag bag) protected booleancasBucket(int bucket, PagesList.Stripe[] exp, PagesList.Stripe[] upd) voidintlongCalculates 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.longinitRecycledPage(long pageId, byte flag, PageIO initIO) Converts recycled page id back to a usable id.voidinsertDataRow(org.apache.ignite.internal.Storable row, IoStatisticsHolder statHolder) voidinsertDataRows(Collection<? extends org.apache.ignite.internal.Storable> 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) longvoidremoveDataRowByLink(long link, IoStatisticsHolder statHolder) longtoString()<S,R> R updateDataRow(long link, org.apache.ignite.internal.PageHandler<S, R> pageHnd, S arg, IoStatisticsHolder statHolder) booleanupdateDataRow(long link, org.apache.ignite.internal.Storable row, IoStatisticsHolder statHolder) Methods inherited from class org.apache.ignite.internal.persistence.freelist.PagesList
bucketsCount, bucketSize, cachedPagesCount, corruptedFreeListException, corruptedFreeListException, corruptedFreeListException, init, initRecycledPage0, initReusedPage, name, put, removeDataPage, saveMetadata, storedPagesCount, stripesCount, takeEmptyPageMethods 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, writeUnlockMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.ignite.internal.persistence.metastorage.MetaStorage
saveMetadata
-
Constructor Details
-
FreeListImpl
public FreeListImpl(int cacheId, String name, int pageSize, DataRegionMetrics memMetrics, PageMemory pageMemory, ReuseList reuseList, WalManager wal, org.apache.ignite.internal.PageAccessHelper pageHandler, long metaPageId, boolean initNew, PageLockListener lockLsnr, IgniteLogger log, AtomicLong pageListCacheLimit) throws IgniteCheckedException - Parameters:
cacheId- Cache ID.name- Name (for debug purpose).pageSize- Page size.memMetrics- Memory metrics.pageMemory- Page memory.reuseList- Reuse list ornullif this free list will be a reuse list for itself.wal- Write ahead log manager.pageHandler- Page access helper.metaPageId- Metadata page ID.initNew-Trueif new metadata should be initialized.lockLsnr- Page lock listener.log- Log.pageListCacheLimit- Page list cache limit.- Throws:
IgniteCheckedException- If failed.
-
-
Method Details
-
freeSpace
public long freeSpace()Calculates free space tracked by this FreeListImpl instance.- Returns:
- Free space available for use, in bytes.
-
dumpStatistics
- Specified by:
dumpStatisticsin interfaceFreeList- 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(org.apache.ignite.internal.Storable row, IoStatisticsHolder statHolder) throws IgniteCheckedException - Specified by:
insertDataRowin interfaceFreeList- Parameters:
row- Row.statHolder- Statistics holder to track IO operations.- Throws:
IgniteCheckedException- If failed.
-
insertDataRows
public void insertDataRows(Collection<? extends org.apache.ignite.internal.Storable> 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- Parameters:
rows- Rows.statHolder- Statistics holder to track IO operations.- Throws:
IgniteCheckedException- If failed.
-
updateDataRow
public boolean updateDataRow(long link, org.apache.ignite.internal.Storable row, IoStatisticsHolder statHolder) throws IgniteCheckedException - Specified by:
updateDataRowin interfaceFreeList- 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.
-
updateDataRow
public <S,R> R updateDataRow(long link, org.apache.ignite.internal.PageHandler<S, R> pageHnd, S arg, IoStatisticsHolder statHolder) throws IgniteCheckedException- Specified by:
updateDataRowin interfaceFreeList- Type Parameters:
S- Argument type.R- Result type.- Parameters:
link- Row link.pageHnd- Page handler.arg- Handler argument.statHolder- Statistics holder to track IO operations.- Returns:
- Result.
- Throws:
IgniteCheckedException- If failed.
-
removeDataRowByLink
public void removeDataRowByLink(long link, IoStatisticsHolder statHolder) throws IgniteCheckedException - Specified by:
removeDataRowByLinkin interfaceFreeList- Parameters:
link- Row link.statHolder- Statistics holder to track IO operations.- Throws:
IgniteCheckedException- If failed.
-
getBucket
-
casBucket
-
isReuseBucket
protected boolean isReuseBucket(int bucket) - Specified by:
isReuseBucketin classPagesList- Parameters:
bucket- Bucket index.- Returns:
trueIf it is a reuse bucket.
-
getBucketCache
- 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
- Specified by:
addForRecyclein interfaceReuseList- Parameters:
bag- Reuse bag.- Throws:
IgniteCheckedException- If failed.
-
takeRecycledPage
- Specified by:
takeRecycledPagein interfaceReuseList- Returns:
- Page ID or
0if none available. - Throws:
IgniteCheckedException- If failed.
-
initRecycledPage
Converts 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.
-
recycledPagesCount
- Specified by:
recycledPagesCountin interfaceReuseList- Returns:
- Number of recycled pages it contains.
- Throws:
IgniteCheckedException- If failed.
-
toString
-