Class IgniteCacheOffheapManagerImpl
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl
-
- All Implemented Interfaces:
IgniteCacheOffheapManager
- Direct Known Subclasses:
GridCacheOffheapManager
public class IgniteCacheOffheapManagerImpl extends Object implements IgniteCacheOffheapManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIgniteCacheOffheapManagerImpl.CacheDataStoreImplprotected static classIgniteCacheOffheapManagerImpl.ExpiredKeyCacheObjectThis entry key is used to indicate that an expired entry has already been deleted from PendingEntriesTree and doesn't need to participate in PendingEntriesTree cleanup again.-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager
IgniteCacheOffheapManager.CacheDataStore, IgniteCacheOffheapManager.OffheapInvokeClosure
-
-
Field Summary
Fields Modifier and Type Field Description protected GridSpinBusyLockbusyLockprotected GridCacheSharedContextctxprotected CacheGroupContextgrpprotected IgniteLoggerlogprotected GridStripedLockpartStoreLockstatic intPRELOAD_SIZE_UNDER_CHECKPOINT_LOCKThe maximum number of entries that can be preloaded under checkpoint read lock.
-
Constructor Summary
Constructors Constructor Description IgniteCacheOffheapManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterable<IgniteCacheOffheapManager.CacheDataStore>cacheDataStores()longcacheEntriesCount(int cacheId)longcacheEntriesCount(int cacheId, boolean primary, boolean backup, AffinityTopologyVersion topVer)longcacheEntriesCount(int cacheId, int part)<K,V>
GridCloseableIterator<javax.cache.Cache.Entry<K,V>>cacheEntriesIterator(GridCacheContext cctx, boolean primary, boolean backup, AffinityTopologyVersion topVer, boolean keepBinary, Boolean dataPageScanEnabled)GridIterator<CacheDataRow>cacheIterator(int cacheId, boolean primary, boolean backups, AffinityTopologyVersion topVer, Boolean dataPageScanEnabled)GridCloseableIterator<KeyCacheObject>cacheKeysIterator(int cacheId, int part)GridIterator<CacheDataRow>cachePartitionIterator(int cacheId, int part, Boolean dataPageScanEnabled)voidclearCache(GridCacheContext cctx, boolean readers)Clears offheap entries.voidconfirmPartitionStatesRestored()Confirm that partition states are restored.booleancontainsKey(GridCacheMapEntry entry)TODO: GG-10884, used on only from initialValue.IgniteCacheOffheapManager.CacheDataStorecreateCacheDataStore(int p)protected IgniteCacheOffheapManager.CacheDataStorecreateCacheDataStore0(int p)IgniteCacheOffheapManager.CacheDataStoredataStore(@Nullable GridDhtLocalPartition part)voiddestroyCacheDataStore(IgniteCacheOffheapManager.CacheDataStore store)protected voiddestroyCacheDataStore0(IgniteCacheOffheapManager.CacheDataStore store)@Nullable RootPagedropRootPageForIndex(int cacheId, String idxName, int segment)Dropping the root page of the index tree.booleanexpire(GridCacheContext cctx, IgniteInClosure2X<GridCacheEntryEx,GridCacheVersion> c, int amount)longexpiredSize()Gets the number of entries pending expire.@Nullable RootPagefindRootPageForIndex(int cacheId, String idxName, int segment)GridAtomicLongglobalRemoveId()booleanhasEntriesPendingExpire(int cacheId)Checks if the cache has entries pending expire.protected @Nullable IgniteHistoricalIteratorhistoricalIterator(CachePartitionPartialCountersMap partCntrs, Set<Integer> missing)protected voidinitDataStructures()protected voidinitPendingTree(GridCacheContext<?,?> cctx)voidinvoke(GridCacheContext cctx, KeyCacheObject key, GridDhtLocalPartition part, IgniteCacheOffheapManager.OffheapInvokeClosure c)longoffHeapAllocatedSize()voidonCacheStarted(GridCacheContext cctx)voidonKernalStop()Callback on node stop.intonUndeploy(ClassLoader ldr)GridIterator<CacheDataRow>partitionIterator(int part)voidpreloadPartition(int partId)Preload a partition.voidprepareToStop()Prepare cache group to stop (due to cache destroy or cluster deactivate).@Nullable CacheDataRowread(GridCacheContext cctx, KeyCacheObject key)@Nullable CacheDataRowread(GridCacheMapEntry entry)IgniteRebalanceIteratorrebalanceIterator(IgniteDhtDemandedPartitionsMap parts, AffinityTopologyVersion topVer)voidremove(GridCacheContext cctx, KeyCacheObject key, int partId, GridDhtLocalPartition part)@Nullable RootPagerenameRootPageForIndex(int cacheId, String oldIdxName, String newIdxName, int segment)Renaming the root page of the index tree.GridCloseableIterator<CacheDataRow>reservedIterator(int part, AffinityTopologyVersion topVer)voidrestorePartitionStates()Pre-create partitions that resides in page memory or WAL and restores their state.longrestoreStateOfPartition(int p, @Nullable Integer recoveryState)Pre-create single partition that resides in page memory or WAL and restores their state.ReuseListreuseListForIndex(String idxName)RootPagerootPageForIndex(int cacheId, String idxName, int segment)voidstart(GridCacheSharedContext ctx, CacheGroupContext grp)voidstop()Stop cache group (due to cache destroy or cluster deactivate).voidstopCache(int cacheId, boolean destroy)voidstoreEntries(GridDhtLocalPartition part, Iterator<GridCacheEntryInfo> infos, IgnitePredicateX<CacheDataRow> initPred)Store entries.protected StringtreeName(int p)voidupdate(GridCacheContext cctx, KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime, GridDhtLocalPartition part, @Nullable CacheDataRow oldRow)
-
-
-
Field Detail
-
PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK
public static final int PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK
The maximum number of entries that can be preloaded under checkpoint read lock.- See Also:
- Constant Field Values
-
ctx
protected GridCacheSharedContext ctx
-
grp
protected CacheGroupContext grp
-
log
protected IgniteLogger log
-
busyLock
protected final GridSpinBusyLock busyLock
-
partStoreLock
protected GridStripedLock partStoreLock
-
-
Method Detail
-
globalRemoveId
public GridAtomicLong globalRemoveId()
- Specified by:
globalRemoveIdin interfaceIgniteCacheOffheapManager- Returns:
- Global remove ID counter.
-
start
public void start(GridCacheSharedContext ctx, CacheGroupContext grp) throws IgniteCheckedException
- Specified by:
startin interfaceIgniteCacheOffheapManager- Parameters:
ctx- Context.grp- Cache group.- Throws:
IgniteCheckedException- If failed.
-
onCacheStarted
public void onCacheStarted(GridCacheContext cctx) throws IgniteCheckedException
- Specified by:
onCacheStartedin interfaceIgniteCacheOffheapManager- Parameters:
cctx- Cache context.- Throws:
IgniteCheckedException- If failed.
-
initPendingTree
protected void initPendingTree(GridCacheContext<?,?> cctx) throws IgniteCheckedException
- Parameters:
cctx- Cache context.- Throws:
IgniteCheckedException- If failed.
-
initDataStructures
protected void initDataStructures() throws IgniteCheckedException- Throws:
IgniteCheckedException- If failed.
-
stopCache
public void stopCache(int cacheId, boolean destroy)- Specified by:
stopCachein interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache ID.destroy- Destroy data flag. Setting totruewill remove all cache data.
-
stop
public void stop()
Stop cache group (due to cache destroy or cluster deactivate).- Specified by:
stopin interfaceIgniteCacheOffheapManager
-
restoreStateOfPartition
public long restoreStateOfPartition(int p, @Nullable @Nullable Integer recoveryState) throws IgniteCheckedExceptionPre-create single partition that resides in page memory or WAL and restores their state.- Specified by:
restoreStateOfPartitionin interfaceIgniteCacheOffheapManager- Parameters:
p- Partition id.recoveryState- Partition recovery state.- Returns:
- Processing time in millis.
- Throws:
IgniteCheckedException- If failed.
-
restorePartitionStates
public void restorePartitionStates() throws IgniteCheckedExceptionPre-create partitions that resides in page memory or WAL and restores their state.- Specified by:
restorePartitionStatesin interfaceIgniteCacheOffheapManager- Throws:
IgniteCheckedException- If failed.
-
confirmPartitionStatesRestored
public void confirmPartitionStatesRestored()
Confirm that partition states are restored. This method should be called after restoring state of all partitions in group usingIgniteCacheOffheapManager.restoreStateOfPartition(int, Integer).- Specified by:
confirmPartitionStatesRestoredin interfaceIgniteCacheOffheapManager
-
onKernalStop
public void onKernalStop()
Callback on node stop.- Specified by:
onKernalStopin interfaceIgniteCacheOffheapManager
-
prepareToStop
public void prepareToStop()
Prepare cache group to stop (due to cache destroy or cluster deactivate).- Specified by:
prepareToStopin interfaceIgniteCacheOffheapManager
-
dataStore
public IgniteCacheOffheapManager.CacheDataStore dataStore(@Nullable @Nullable GridDhtLocalPartition part)
- Specified by:
dataStorein interfaceIgniteCacheOffheapManager- Parameters:
part- Local partition ornullif a related cache group is LOCAL.- Returns:
- Cache data store associated with given partition or the cache data store for a LOCAL cache group.
-
cacheEntriesCount
public long cacheEntriesCount(int cacheId)
- Specified by:
cacheEntriesCountin interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache ID.- Returns:
- Number of entries.
-
preloadPartition
public void preloadPartition(int partId) throws IgniteCheckedExceptionPreload a partition. Must be called under partition reservation for DHT caches.- Specified by:
preloadPartitionin interfaceIgniteCacheOffheapManager- Parameters:
partId- Partition id.- Throws:
IgniteCheckedException- If failed.
-
cacheEntriesCount
public long cacheEntriesCount(int cacheId, boolean primary, boolean backup, AffinityTopologyVersion topVer)- Specified by:
cacheEntriesCountin interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache ID.primary- Primary entries flag.backup- Backup entries flag.topVer- Topology version.- Returns:
- Entries count.
-
cacheEntriesCount
public long cacheEntriesCount(int cacheId, int part)- Specified by:
cacheEntriesCountin interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache ID.part- Partition.- Returns:
- Number of entries in given partition.
-
cacheDataStores
public Iterable<IgniteCacheOffheapManager.CacheDataStore> cacheDataStores()
- Specified by:
cacheDataStoresin interfaceIgniteCacheOffheapManager- Returns:
- Iterable over all existing cache data stores.
-
invoke
public void invoke(GridCacheContext cctx, KeyCacheObject key, GridDhtLocalPartition part, IgniteCacheOffheapManager.OffheapInvokeClosure c) throws IgniteCheckedException
- Specified by:
invokein interfaceIgniteCacheOffheapManager- Parameters:
cctx- Cache context.key- Key.part- Partition.c- Tree update closure.- Throws:
IgniteCheckedException- If failed.
-
update
public void update(GridCacheContext cctx, KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime, GridDhtLocalPartition part, @Nullable @Nullable CacheDataRow oldRow) throws IgniteCheckedException
- Specified by:
updatein interfaceIgniteCacheOffheapManager- Parameters:
cctx- Cache context.key- Key.val- Value.ver- Version.expireTime- Expire time.part- Partition.oldRow- Old row if available.- Throws:
IgniteCheckedException- If failed.
-
remove
public void remove(GridCacheContext cctx, KeyCacheObject key, int partId, GridDhtLocalPartition part) throws IgniteCheckedException
- Specified by:
removein interfaceIgniteCacheOffheapManager- Parameters:
cctx- Cache context.key- Key.partId- Partition number.part- Partition.- Throws:
IgniteCheckedException- If failed.
-
read
@Nullable public @Nullable CacheDataRow read(GridCacheMapEntry entry) throws IgniteCheckedException
- Specified by:
readin interfaceIgniteCacheOffheapManager- Parameters:
entry- Cache entry.- Returns:
- Cached row, if available, null otherwise.
- Throws:
IgniteCheckedException- If failed.
-
read
@Nullable public @Nullable CacheDataRow read(GridCacheContext cctx, KeyCacheObject key) throws IgniteCheckedException
- Specified by:
readin interfaceIgniteCacheOffheapManager- Parameters:
cctx- Cache context.key- Key.- Returns:
- Cached row, if available, null otherwise.
- Throws:
IgniteCheckedException- If failed.
-
containsKey
public boolean containsKey(GridCacheMapEntry entry)
TODO: GG-10884, used on only from initialValue.- Specified by:
containsKeyin interfaceIgniteCacheOffheapManager
-
clearCache
public void clearCache(GridCacheContext cctx, boolean readers)
Clears offheap entries.- Specified by:
clearCachein interfaceIgniteCacheOffheapManager- Parameters:
readers-Trueto clear readers.cctx- Cache context.
-
onUndeploy
public int onUndeploy(ClassLoader ldr)
- Specified by:
onUndeployin interfaceIgniteCacheOffheapManager- Parameters:
ldr- Class loader.- Returns:
- Number of undeployed entries.
-
offHeapAllocatedSize
public long offHeapAllocatedSize()
- Specified by:
offHeapAllocatedSizein interfaceIgniteCacheOffheapManager- Returns:
- Offheap allocated size.
-
cacheEntriesIterator
public <K,V> GridCloseableIterator<javax.cache.Cache.Entry<K,V>> cacheEntriesIterator(GridCacheContext cctx, boolean primary, boolean backup, AffinityTopologyVersion topVer, boolean keepBinary, Boolean dataPageScanEnabled)
- Specified by:
cacheEntriesIteratorin interfaceIgniteCacheOffheapManager- Parameters:
cctx- Cache context.primary-Trueif need to return primary entries.backup-Trueif need to return backup entries.topVer- Topology version.keepBinary- Keep binary flag.dataPageScanEnabled- Flag to enable data page scan.- Returns:
- Entries iterator.
-
cacheKeysIterator
public GridCloseableIterator<KeyCacheObject> cacheKeysIterator(int cacheId, int part) throws IgniteCheckedException
- Specified by:
cacheKeysIteratorin interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache ID.part- Partition.- Returns:
- Iterator.
- Throws:
IgniteCheckedException- If failed.
-
cacheIterator
public GridIterator<CacheDataRow> cacheIterator(int cacheId, boolean primary, boolean backups, AffinityTopologyVersion topVer, Boolean dataPageScanEnabled)
- Specified by:
cacheIteratorin interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache ID.primary- Primary entries flag.backups- Backup entries flag.topVer- Topology version.dataPageScanEnabled- Flag to enable data page scan.- Returns:
- Rows iterator.
-
cachePartitionIterator
public GridIterator<CacheDataRow> cachePartitionIterator(int cacheId, int part, Boolean dataPageScanEnabled)
- Specified by:
cachePartitionIteratorin interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache ID.part- Partition.dataPageScanEnabled- Flag to enable data page scan.- Returns:
- Partition data iterator.
-
partitionIterator
public GridIterator<CacheDataRow> partitionIterator(int part)
- Specified by:
partitionIteratorin interfaceIgniteCacheOffheapManager- Parameters:
part- Partition number.- Returns:
- Iterator for given partition.
-
rootPageForIndex
public RootPage rootPageForIndex(int cacheId, String idxName, int segment) throws IgniteCheckedException
- Specified by:
rootPageForIndexin interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache ID.idxName- Index name.segment- Segment.- Returns:
- Root page for index tree.
- Throws:
IgniteCheckedException- If failed.
-
findRootPageForIndex
@Nullable public @Nullable RootPage findRootPageForIndex(int cacheId, String idxName, int segment) throws IgniteCheckedException
- Specified by:
findRootPageForIndexin interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache ID.idxName- Index name.- Throws:
IgniteCheckedException- If failed.
-
dropRootPageForIndex
@Nullable public @Nullable RootPage dropRootPageForIndex(int cacheId, String idxName, int segment) throws IgniteCheckedException
Dropping the root page of the index tree.- Specified by:
dropRootPageForIndexin interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache ID.idxName- Index name.segment- Segment index.- Returns:
- Dropped root page of the index tree.
- Throws:
IgniteCheckedException- If failed.
-
renameRootPageForIndex
@Nullable public @Nullable RootPage renameRootPageForIndex(int cacheId, String oldIdxName, String newIdxName, int segment) throws IgniteCheckedException
Renaming the root page of the index tree.- Specified by:
renameRootPageForIndexin interfaceIgniteCacheOffheapManager- Parameters:
cacheId- Cache id.oldIdxName- Old name of the index tree.newIdxName- New name of the index tree.segment- Segment index.- Returns:
- Renamed root page of the index tree.
- Throws:
IgniteCheckedException- If failed.
-
reuseListForIndex
public ReuseList reuseListForIndex(String idxName)
- Specified by:
reuseListForIndexin interfaceIgniteCacheOffheapManager- Parameters:
idxName- Index name.- Returns:
- Reuse list for index tree.
-
reservedIterator
public GridCloseableIterator<CacheDataRow> reservedIterator(int part, AffinityTopologyVersion topVer)
- Specified by:
reservedIteratorin interfaceIgniteCacheOffheapManager- Parameters:
part- Partition number.topVer- Topology version.- Returns:
- Iterator for given partition that will reserve partition state until it is closed.
-
rebalanceIterator
public IgniteRebalanceIterator rebalanceIterator(IgniteDhtDemandedPartitionsMap parts, AffinityTopologyVersion topVer) throws IgniteCheckedException
- Specified by:
rebalanceIteratorin interfaceIgniteCacheOffheapManager- Parameters:
parts- Partitions.- Returns:
- Partition data iterator.
- Throws:
IgniteCheckedException- If failed.
-
historicalIterator
@Nullable protected @Nullable IgniteHistoricalIterator historicalIterator(CachePartitionPartialCountersMap partCntrs, Set<Integer> missing) throws IgniteCheckedException
- Parameters:
partCntrs- Partition counters map.missing- Set of partitions need to populate if partition is missing or failed to reserve.- Returns:
- Historical iterator.
- Throws:
IgniteCheckedException- If failed.
-
storeEntries
public void storeEntries(GridDhtLocalPartition part, Iterator<GridCacheEntryInfo> infos, IgnitePredicateX<CacheDataRow> initPred) throws IgniteCheckedException
Store entries.- Specified by:
storeEntriesin interfaceIgniteCacheOffheapManager- Parameters:
part- Local partition.infos- Entry infos.initPred- Applied to all created rows. Each row that not matches the predicate is removed.- Throws:
IgniteCheckedException- If failed.
-
createCacheDataStore
public final IgniteCacheOffheapManager.CacheDataStore createCacheDataStore(int p) throws IgniteCheckedException
- Specified by:
createCacheDataStorein interfaceIgniteCacheOffheapManager- Parameters:
p- Partition.- Returns:
- Data store.
- Throws:
IgniteCheckedException- If failed.
-
createCacheDataStore0
protected IgniteCacheOffheapManager.CacheDataStore createCacheDataStore0(int p) throws IgniteCheckedException
- Parameters:
p- Partition.- Returns:
- Cache data store.
- Throws:
IgniteCheckedException- If failed.
-
destroyCacheDataStore
public final void destroyCacheDataStore(IgniteCacheOffheapManager.CacheDataStore store) throws IgniteCheckedException
- Specified by:
destroyCacheDataStorein interfaceIgniteCacheOffheapManager- Parameters:
store- Data store.- Throws:
IgniteCheckedException- If failed.
-
destroyCacheDataStore0
protected void destroyCacheDataStore0(IgniteCacheOffheapManager.CacheDataStore store) throws IgniteCheckedException
- Parameters:
store- Cache data store.- Throws:
IgniteCheckedException- If failed.
-
treeName
protected final String treeName(int p)
- Parameters:
p- Partition.- Returns:
- Tree name for given partition.
-
expire
public boolean expire(GridCacheContext cctx, IgniteInClosure2X<GridCacheEntryEx,GridCacheVersion> c, int amount) throws IgniteCheckedException
- Specified by:
expirein interfaceIgniteCacheOffheapManager- Parameters:
cctx- Cache context.c- Closure.amount- Limit of processed entries by single call,-1for no limit.- Returns:
Trueif unprocessed expired entries remains.- Throws:
IgniteCheckedException- If failed.
-
expiredSize
public long expiredSize() throws IgniteCheckedExceptionGets the number of entries pending expire.- Specified by:
expiredSizein interfaceIgniteCacheOffheapManager- 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.- Specified by:
hasEntriesPendingExpirein interfaceIgniteCacheOffheapManager- Returns:
Trueif there are entries pending expire.- Throws:
IgniteCheckedException- If failed to get number of pending entries.
-
-