Class GridCacheOffheapManager
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl
-
- org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager
-
- All Implemented Interfaces:
IgniteCacheOffheapManager,CheckpointListener
public class GridCacheOffheapManager extends IgniteCacheOffheapManagerImpl implements CheckpointListener
Used when persistence enabled.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGridCacheOffheapManager.GridCacheDataStore-
Nested classes/interfaces inherited from class org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl
IgniteCacheOffheapManagerImpl.CacheDataStoreImpl, IgniteCacheOffheapManagerImpl.ExpiredKeyCacheObject
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointListener
CheckpointListener.Context
-
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 static intDFLT_WAL_MARGIN_FOR_ATOMIC_CACHE_HISTORICAL_REBALANCEstatic GridCursor<CacheDataRow>EMPTY_CURSORstatic StringWAL_MARGIN_FOR_ATOMIC_CACHE_HISTORICAL_REBALANCE-
Fields inherited from class org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl
busyLock, ctx, grp, log, partStoreLock, PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK
-
-
Constructor Summary
Constructors Constructor Description GridCacheOffheapManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeforeCheckpointBegin(CheckpointListener.Context ctx)Do some actions before checkpoint write lock.voidconfirmPartitionStatesRestored()Confirm that partition states are restored.protected IgniteCacheOffheapManager.CacheDataStorecreateCacheDataStore0(int p)GridCacheOffheapManager.GridCacheDataStorecreateGridCacheDataStore(CacheGroupContext grpCtx, int partId, boolean exists, IgniteLogger log)protected voiddestroyCacheDataStore0(IgniteCacheOffheapManager.CacheDataStore store)voiddestroyPartitionStore(int partId)Invalidates page memory for given partition.@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.voidfindAndCleanupLostIndexesForStoppedCache(int cacheId)@Nullable RootPagefindRootPageForIndex(int cacheId, String idxName, int segment)IndexStoragegetIndexStorage()Get internal IndexStorage.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)voidonCheckpointBegin(CheckpointListener.Context ctx)voidonMarkCheckpointBegin(CheckpointListener.Context ctx)voidpreloadPartition(int partId)Preload a partition.static @Nullable Map<Integer,Long>readSharedGroupCacheSizes(PageSupport pageMem, int grpId, long cntrsPageId)Loads cache sizes for all caches in shared group.@Nullable RootPagerenameRootPageForIndex(int cacheId, String oldIdxName, String newIdxName, int segment)Renaming the root page of the index tree.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)voidstop()Stop cache group (due to cache destroy or cluster deactivate).static longwriteSharedGroupCacheSizes(PageMemory pageMem, int grpId, long cntrsPageId, int partId, Map<Integer,Long> sizes)Saves cache sizes for all caches in shared group.-
Methods inherited from class org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl
cacheDataStores, cacheEntriesCount, cacheEntriesCount, cacheEntriesCount, cacheEntriesIterator, cacheIterator, cacheKeysIterator, cachePartitionIterator, clearCache, containsKey, createCacheDataStore, dataStore, destroyCacheDataStore, globalRemoveId, invoke, offHeapAllocatedSize, onCacheStarted, onKernalStop, onUndeploy, partitionIterator, prepareToStop, read, read, rebalanceIterator, remove, reservedIterator, start, stopCache, storeEntries, treeName, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointListener
afterCheckpointEnd
-
-
-
-
Field Detail
-
DFLT_WAL_MARGIN_FOR_ATOMIC_CACHE_HISTORICAL_REBALANCE
public static final int DFLT_WAL_MARGIN_FOR_ATOMIC_CACHE_HISTORICAL_REBALANCE
-
WAL_MARGIN_FOR_ATOMIC_CACHE_HISTORICAL_REBALANCE
@SystemProperty(value="The WAL iterator margin that is used to prevent partitions divergence on the historical rebalance of atomic caches", type=java.lang.Long.class, defaults="5") public static final String WAL_MARGIN_FOR_ATOMIC_CACHE_HISTORICAL_REBALANCE
- See Also:
- Constant Field Values
-
EMPTY_CURSOR
public static final GridCursor<CacheDataRow> EMPTY_CURSOR
-
-
Method Detail
-
initPendingTree
protected void initPendingTree(GridCacheContext cctx) throws IgniteCheckedException
- Overrides:
initPendingTreein classIgniteCacheOffheapManagerImpl- Parameters:
cctx- Cache context.- Throws:
IgniteCheckedException- If failed.
-
initDataStructures
protected void initDataStructures() throws IgniteCheckedException- Overrides:
initDataStructuresin classIgniteCacheOffheapManagerImpl- Throws:
IgniteCheckedException- If failed.
-
getIndexStorage
public IndexStorage getIndexStorage()
Get internal IndexStorage. SeeUpgradePendingTreeToPerPartitionTaskfor details.
-
createCacheDataStore0
protected IgniteCacheOffheapManager.CacheDataStore createCacheDataStore0(int p) throws IgniteCheckedException
- Overrides:
createCacheDataStore0in classIgniteCacheOffheapManagerImpl- Parameters:
p- Partition.- Returns:
- Cache data store.
- Throws:
IgniteCheckedException- If failed.
-
onCheckpointBegin
public void onCheckpointBegin(CheckpointListener.Context ctx) throws IgniteCheckedException
- Specified by:
onCheckpointBeginin interfaceCheckpointListener- Throws:
IgniteCheckedException- If failed.
-
onMarkCheckpointBegin
public void onMarkCheckpointBegin(CheckpointListener.Context ctx) throws IgniteCheckedException
- Specified by:
onMarkCheckpointBeginin interfaceCheckpointListener- Throws:
IgniteCheckedException- If failed.
-
beforeCheckpointBegin
public void beforeCheckpointBegin(CheckpointListener.Context ctx) throws IgniteCheckedException
Do some actions before checkpoint write lock.- Specified by:
beforeCheckpointBeginin interfaceCheckpointListener- Throws:
IgniteCheckedException- If failed.
-
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- Overrides:
restoreStateOfPartitionin classIgniteCacheOffheapManagerImpl- 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- Overrides:
restorePartitionStatesin classIgniteCacheOffheapManagerImpl- 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- Overrides:
confirmPartitionStatesRestoredin classIgniteCacheOffheapManagerImpl
-
readSharedGroupCacheSizes
@Nullable public static @Nullable Map<Integer,Long> readSharedGroupCacheSizes(PageSupport pageMem, int grpId, long cntrsPageId) throws IgniteCheckedException
Loads cache sizes for all caches in shared group.- Parameters:
pageMem- page memory to perform operations on pages.grpId- Cache group ID.cntrsPageId- Counters page ID, if zero is provided that means no counters page exist.- Returns:
- Cache sizes if store belongs to group containing multiple caches and sizes are available in memory. May return null if counter page does not exist.
- Throws:
IgniteCheckedException- If page memory operation failed.
-
writeSharedGroupCacheSizes
public static long writeSharedGroupCacheSizes(PageMemory pageMem, int grpId, long cntrsPageId, int partId, Map<Integer,Long> sizes) throws IgniteCheckedException
Saves cache sizes for all caches in shared group. Unconditionally marks pages as dirty.- Parameters:
pageMem- page memory to perform operations on pages.grpId- Cache group ID.cntrsPageId- Counters page ID, if zero is provided that means no counters page exist.partId- Partition ID.sizes- Cache sizes of all caches in group. Not null.- Returns:
- new counter page Id. Same as
cntrsPageIdor new value if cache size pages were initialized. - Throws:
IgniteCheckedException- if page memory operation failed.
-
destroyCacheDataStore0
protected void destroyCacheDataStore0(IgniteCacheOffheapManager.CacheDataStore store) throws IgniteCheckedException
- Overrides:
destroyCacheDataStore0in classIgniteCacheOffheapManagerImpl- Parameters:
store- Cache data store.- Throws:
IgniteCheckedException- If failed.
-
destroyPartitionStore
public void destroyPartitionStore(int partId) throws IgniteCheckedExceptionInvalidates page memory for given partition. Destroys partition store. NOTE: This method can be invoked only within checkpoint lock or checkpointer thread.- Parameters:
partId- Partition ID.- Throws:
IgniteCheckedException- If destroy has failed.
-
rootPageForIndex
public RootPage rootPageForIndex(int cacheId, String idxName, int segment) throws IgniteCheckedException
- Specified by:
rootPageForIndexin interfaceIgniteCacheOffheapManager- Overrides:
rootPageForIndexin classIgniteCacheOffheapManagerImpl- 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- Overrides:
findRootPageForIndexin classIgniteCacheOffheapManagerImpl- 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- Overrides:
dropRootPageForIndexin classIgniteCacheOffheapManagerImpl- 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- Overrides:
renameRootPageForIndexin classIgniteCacheOffheapManagerImpl- 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- Overrides:
reuseListForIndexin classIgniteCacheOffheapManagerImpl- Parameters:
idxName- Index name.- Returns:
- Reuse list for index tree.
-
stop
public void stop()
Stop cache group (due to cache destroy or cluster deactivate).- Specified by:
stopin interfaceIgniteCacheOffheapManager- Overrides:
stopin classIgniteCacheOffheapManagerImpl
-
historicalIterator
@Nullable protected @Nullable IgniteHistoricalIterator historicalIterator(CachePartitionPartialCountersMap partCntrs, Set<Integer> missing) throws IgniteCheckedException
- Overrides:
historicalIteratorin classIgniteCacheOffheapManagerImpl- 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.
-
expire
public boolean expire(GridCacheContext cctx, IgniteInClosure2X<GridCacheEntryEx,GridCacheVersion> c, int amount) throws IgniteCheckedException
- Specified by:
expirein interfaceIgniteCacheOffheapManager- Overrides:
expirein classIgniteCacheOffheapManagerImpl- 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- Overrides:
expiredSizein classIgniteCacheOffheapManagerImpl- 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- Overrides:
hasEntriesPendingExpirein classIgniteCacheOffheapManagerImpl- Returns:
Trueif there are entries pending expire.- Throws:
IgniteCheckedException- If failed to get number of pending entries.
-
preloadPartition
public void preloadPartition(int partId) throws IgniteCheckedExceptionPreload a partition. Must be called under partition reservation for DHT caches.- Specified by:
preloadPartitionin interfaceIgniteCacheOffheapManager- Overrides:
preloadPartitionin classIgniteCacheOffheapManagerImpl- Parameters:
partId- Partition id.- Throws:
IgniteCheckedException- If failed.
-
findAndCleanupLostIndexesForStoppedCache
public void findAndCleanupLostIndexesForStoppedCache(int cacheId) throws IgniteCheckedException- Parameters:
cacheId- Which was stopped, but its data still presented.- Throws:
IgniteCheckedException- If failed.
-
createGridCacheDataStore
public GridCacheOffheapManager.GridCacheDataStore createGridCacheDataStore(CacheGroupContext grpCtx, int partId, boolean exists, IgniteLogger log)
-
-