Class GridCacheOffheapManager.GridCacheDataStore
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager.GridCacheDataStore
-
- All Implemented Interfaces:
IgniteCacheOffheapManager.CacheDataStore
- Enclosing class:
- GridCacheOffheapManager
public static class GridCacheOffheapManager.GridCacheDataStore extends Object implements IgniteCacheOffheapManager.CacheDataStore
-
-
Constructor Summary
Constructors Constructor Description GridCacheDataStore(CacheGroupContext grp, int partId, boolean exists, GridSpinBusyLock busyLock, IgniteLogger log)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcacheSize(int cacheId)Map<Integer,Long>cacheSizes()voidclear(int cacheId)Clears all the records associated with logical cache with given ID.CacheDataRowcreateRow(GridCacheContext cctx, KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime, @Nullable CacheDataRow oldRow)GridCursor<? extends CacheDataRow>cursor()GridCursor<? extends CacheDataRow>cursor(int cacheId)GridCursor<? extends CacheDataRow>cursor(int cacheId, KeyCacheObject lower, KeyCacheObject upper)GridCursor<? extends CacheDataRow>cursor(int cacheId, KeyCacheObject lower, KeyCacheObject upper, Object x)GridCursor<? extends CacheDataRow>cursor(Object x)voiddestroy()Destroys the tree associated with the store.booleandestroyed()longexpiredSize()Gets the number of entries pending expire.GridLongListfinalizeUpdateCounters()Flushes pending update counters closing all possible gaps.CacheDataRowfind(GridCacheContext cctx, KeyCacheObject key)longfullSize()longgetAndIncrementUpdateCounter(long delta)Returns current value and updates counter by delta.AbstractFreeList<CacheDataRow>getCacheStoreFreeList()booleanhasEntriesPendingExpire(int cacheId)Checks if the cache has entries pending expire.longhighestAppliedCounter()booleaninit()Initialize data store if it exists.longinitialUpdateCounter()voidinsertRows(Collection<DataRowCacheAware> rows, IgnitePredicateX<CacheDataRow> initPred)Insert rows into page memory.voidinvoke(GridCacheContext cctx, KeyCacheObject key, IgniteCacheOffheapManager.OffheapInvokeClosure c)booleanisEmpty()voidmarkDestroyed()Mark store as destroyed.longnextUpdateCounter()intpartId()PartitionMetaStorage<SimpleDataRow>partStorage()Partition storage.PartitionUpdateCounterpartUpdateCounter()PendingEntriesTreependingTree()Return PendingTree for data store.voidpreload()Preload a store into page memory.intpurgeExpired(GridCacheContext cctx, IgniteInClosure2X<GridCacheEntryEx,GridCacheVersion> c, long throttlingTimeout, int amount)Try to remove expired entries from data store.voidremove(GridCacheContext cctx, KeyCacheObject key, int partId)longreserve(long delta)longreservedCounter()voidresetInitialUpdateCounter()Reset the initial value of the partition counter.voidresetUpdateCounter()Reset counter for partition.RowStorerowStore()voidsetRowCacheCleaner(GridQueryRowCacheCleaner rowCacheCleaner)Inject rows cache cleaner.CacheDataTreetree()voidupdate(GridCacheContext cctx, KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime, @Nullable CacheDataRow oldRow)longupdateCounter()voidupdateCounter(long val)booleanupdateCounter(long start, long delta)Updates counters from start value by delta value.voidupdateInitialCounter(long start, long delta)voidupdateSize(int cacheId, long delta)Updates size metric for particular cache.
-
-
-
Constructor Detail
-
GridCacheDataStore
public GridCacheDataStore(CacheGroupContext grp, int partId, boolean exists, GridSpinBusyLock busyLock, IgniteLogger log)
- Parameters:
partId- Partition.exists-Trueif store exists.
-
-
Method Detail
-
getCacheStoreFreeList
public AbstractFreeList<CacheDataRow> getCacheStoreFreeList()
-
tree
public CacheDataTree tree()
- Specified by:
treein interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Cache data tree object.
-
init
public boolean init()
Initialize data store if it exists.- Specified by:
initin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
Trueif initialized.
-
partId
public int partId()
- Specified by:
partIdin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Partition ID.
-
rowStore
public RowStore rowStore()
- Specified by:
rowStorein interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Row store.
-
fullSize
public long fullSize()
- Specified by:
fullSizein interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Total size.
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
Trueif there are no items in the store.
-
cacheSize
public long cacheSize(int cacheId)
- Specified by:
cacheSizein interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cacheId- Cache ID.- Returns:
- Size.
-
cacheSizes
public Map<Integer,Long> cacheSizes()
- Specified by:
cacheSizesin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Cache sizes if store belongs to group containing multiple caches.
-
updateSize
public void updateSize(int cacheId, long delta)Updates size metric for particular cache.- Specified by:
updateSizein interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cacheId- Cache ID.delta- Size delta.
-
updateCounter
public long updateCounter()
- Specified by:
updateCounterin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Update counter (LWM).
-
highestAppliedCounter
public long highestAppliedCounter()
- Specified by:
highestAppliedCounterin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Highest applied update counter.
-
reservedCounter
public long reservedCounter()
- Specified by:
reservedCounterin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Reserved counter (HWM).
-
partUpdateCounter
public PartitionUpdateCounter partUpdateCounter()
- Specified by:
partUpdateCounterin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Update counter or
nullif store is not yet created.
-
getAndIncrementUpdateCounter
public long getAndIncrementUpdateCounter(long delta)
Returns current value and updates counter by delta.- Specified by:
getAndIncrementUpdateCounterin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
delta- Delta.- Returns:
- Current value.
-
reserve
public long reserve(long delta)
- Specified by:
reservein interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
delta- Delta.
-
updateCounter
public void updateCounter(long val)
- Specified by:
updateCounterin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
val- Update counter.
-
updateCounter
public boolean updateCounter(long start, long delta)Updates counters from start value by delta value.- Specified by:
updateCounterin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
start- Start.delta- Delta.
-
finalizeUpdateCounters
public GridLongList finalizeUpdateCounters()
Flushes pending update counters closing all possible gaps.- Specified by:
finalizeUpdateCountersin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Even-length array of pairs [start, end] for each gap.
-
nextUpdateCounter
public long nextUpdateCounter()
- Specified by:
nextUpdateCounterin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Next update counter.
-
initialUpdateCounter
public long initialUpdateCounter()
- Specified by:
initialUpdateCounterin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Initial update counter.
-
updateInitialCounter
public void updateInitialCounter(long start, long delta)- Specified by:
updateInitialCounterin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
start- Counter.delta- Delta.
-
setRowCacheCleaner
public void setRowCacheCleaner(GridQueryRowCacheCleaner rowCacheCleaner)
Inject rows cache cleaner.- Specified by:
setRowCacheCleanerin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
rowCacheCleaner- Rows cache cleaner.
-
update
public void update(GridCacheContext cctx, KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime, @Nullable @Nullable CacheDataRow oldRow) throws IgniteCheckedException
- Specified by:
updatein interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cctx- Cache context.key- Key.val- Value.ver- Version.expireTime- Expire time.oldRow- Old row if available.- Throws:
IgniteCheckedException- If failed.
-
createRow
public CacheDataRow createRow(GridCacheContext cctx, KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime, @Nullable @Nullable CacheDataRow oldRow) throws IgniteCheckedException
- Specified by:
createRowin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cctx- Cache context.key- Key.val- Value.ver- Version.expireTime- Expire time.oldRow- Old row.- Returns:
- New row.
- Throws:
IgniteCheckedException- If failed.
-
insertRows
public void insertRows(Collection<DataRowCacheAware> rows, IgnitePredicateX<CacheDataRow> initPred) throws IgniteCheckedException
Insert rows into page memory.- Specified by:
insertRowsin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
rows- Rows.initPred- Applied to all rows. Each row that not matches the predicate is removed.- Throws:
IgniteCheckedException- If failed.
-
invoke
public void invoke(GridCacheContext cctx, KeyCacheObject key, IgniteCacheOffheapManager.OffheapInvokeClosure c) throws IgniteCheckedException
- Specified by:
invokein interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cctx- Cache context.key- Key.c- Closure.- Throws:
IgniteCheckedException- If failed.
-
remove
public void remove(GridCacheContext cctx, KeyCacheObject key, int partId) throws IgniteCheckedException
- Specified by:
removein interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cctx- Cache context.key- Key.partId- Partition number.- Throws:
IgniteCheckedException- If failed.
-
find
public CacheDataRow find(GridCacheContext cctx, KeyCacheObject key) throws IgniteCheckedException
- Specified by:
findin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cctx- Cache context.key- Key.- Returns:
- Data row.
- Throws:
IgniteCheckedException- If failed.
-
cursor
public GridCursor<? extends CacheDataRow> cursor() throws IgniteCheckedException
- Specified by:
cursorin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- Data cursor.
- Throws:
IgniteCheckedException- If failed.
-
cursor
public GridCursor<? extends CacheDataRow> cursor(Object x) throws IgniteCheckedException
- Specified by:
cursorin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
x- Implementation specific argument,nullalways means that we need to return full detached data row.- Returns:
- Data cursor.
- Throws:
IgniteCheckedException- If failed.
-
cursor
public GridCursor<? extends CacheDataRow> cursor(int cacheId, KeyCacheObject lower, KeyCacheObject upper) throws IgniteCheckedException
- Specified by:
cursorin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cacheId- Cache ID.lower- Lower bound.upper- Upper bound.- Returns:
- Data cursor.
- Throws:
IgniteCheckedException- If failed.
-
cursor
public GridCursor<? extends CacheDataRow> cursor(int cacheId, KeyCacheObject lower, KeyCacheObject upper, Object x) throws IgniteCheckedException
- Specified by:
cursorin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cacheId- Cache ID.lower- Lower bound.upper- Upper bound.x- Implementation specific argument,nullalways means that we need to return full detached data row.- Returns:
- Data cursor.
- Throws:
IgniteCheckedException- If failed.
-
destroy
public void destroy() throws IgniteCheckedExceptionDestroys the tree associated with the store.- Specified by:
destroyin interfaceIgniteCacheOffheapManager.CacheDataStore- Throws:
IgniteCheckedException- If failed.
-
markDestroyed
public void markDestroyed() throws IgniteCheckedExceptionMark store as destroyed.- Specified by:
markDestroyedin interfaceIgniteCacheOffheapManager.CacheDataStore- Throws:
IgniteCheckedException
-
destroyed
public boolean destroyed()
- Specified by:
destroyedin interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
trueIf marked as destroyed.
-
cursor
public GridCursor<? extends CacheDataRow> cursor(int cacheId) throws IgniteCheckedException
- Specified by:
cursorin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cacheId- Cache ID.- Returns:
- Data cursor.
- Throws:
IgniteCheckedException- If failed.
-
clear
public void clear(int cacheId) throws IgniteCheckedExceptionClears all the records associated with logical cache with given ID.- Specified by:
clearin interfaceIgniteCacheOffheapManager.CacheDataStore- Parameters:
cacheId- Cache ID.- Throws:
IgniteCheckedException- If failed.
-
expiredSize
public long expiredSize() throws IgniteCheckedExceptionGets the number of entries pending expire.- Returns:
- Number of pending entries.
- Throws:
IgniteCheckedException- If failed to get number of pending entries.
-
hasEntriesPendingExpire
public boolean hasEntriesPendingExpire(int cacheId) throws IgniteCheckedExceptionChecks if the cache has entries pending expire.- Returns:
Trueif there are entries pending expire.- Throws:
IgniteCheckedException- If failed to get number of pending entries.
-
purgeExpired
public int purgeExpired(GridCacheContext cctx, IgniteInClosure2X<GridCacheEntryEx,GridCacheVersion> c, long throttlingTimeout, int amount) throws IgniteCheckedException
Try to remove expired entries from data store.- Parameters:
cctx- Cache context.c- Expiry closure that should be applied to expired entry. SeeGridCacheTtlManagerfor details.amount- Limit of processed entries by single call,-1for no limit.- Returns:
- cleared entries count.
- Throws:
IgniteCheckedException- If failed.
-
pendingTree
public PendingEntriesTree pendingTree()
Return PendingTree for data store.- Specified by:
pendingTreein interfaceIgniteCacheOffheapManager.CacheDataStore- Returns:
- PendingTree instance.
-
preload
public void preload() throws IgniteCheckedExceptionPreload a store into page memory.- Specified by:
preloadin interfaceIgniteCacheOffheapManager.CacheDataStore- Throws:
IgniteCheckedException- If failed.
-
resetUpdateCounter
public void resetUpdateCounter()
Reset counter for partition.- Specified by:
resetUpdateCounterin interfaceIgniteCacheOffheapManager.CacheDataStore
-
resetInitialUpdateCounter
public void resetInitialUpdateCounter()
Reset the initial value of the partition counter.- Specified by:
resetInitialUpdateCounterin interfaceIgniteCacheOffheapManager.CacheDataStore
-
partStorage
public PartitionMetaStorage<SimpleDataRow> partStorage()
Description copied from interface:IgniteCacheOffheapManager.CacheDataStorePartition storage.- Specified by:
partStoragein interfaceIgniteCacheOffheapManager.CacheDataStore
-
-