org.apache.ignite.internal.processors.cache

## 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
`protected class` `IgniteCacheOffheapManagerImpl.CacheDataRowStore`
`protected class` `IgniteCacheOffheapManagerImpl.CacheDataStoreImpl`
`protected static class` `IgniteCacheOffheapManagerImpl.CacheDataTree`
`static class` `IgniteCacheOffheapManagerImpl.CacheIdAwareDataInnerIO`
`static class` `IgniteCacheOffheapManagerImpl.CacheIdAwareDataLeafIO`
`static class` `IgniteCacheOffheapManagerImpl.CacheIdAwarePendingEntryInnerIO`
`static class` `IgniteCacheOffheapManagerImpl.CacheIdAwarePendingEntryLeafIO`
`static class` `IgniteCacheOffheapManagerImpl.DataInnerIO`
`static class` `IgniteCacheOffheapManagerImpl.DataLeafIO`
`protected static class` `IgniteCacheOffheapManagerImpl.PendingEntriesTree`
`static class` `IgniteCacheOffheapManagerImpl.PendingEntryInnerIO`
`static class` `IgniteCacheOffheapManagerImpl.PendingEntryLeafIO`

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager

`IgniteCacheOffheapManager.CacheDataStore, IgniteCacheOffheapManager.OffheapInvokeClosure`

### Field Summary

Fields
`protected GridCacheSharedContext` `ctx`
`protected CacheGroupContext` `grp`
`protected IgniteLogger` `log`
`protected ConcurrentMap<Integer,IgniteCacheOffheapManager.CacheDataStore>` `partDataStores`
`protected IgniteCacheOffheapManagerImpl.PendingEntriesTree` `pendingEntries`

### Constructor Summary

Constructors
Constructor and Description
`IgniteCacheOffheapManagerImpl()`

### Method Summary

Methods
`Iterable<IgniteCacheOffheapManager.CacheDataStore>` `cacheDataStores()`
`long` `cacheEntriesCount(int cacheId)`
`long` `cacheEntriesCount(int cacheId, boolean primary, boolean backup, AffinityTopologyVersion topVer)`
`long` `cacheEntriesCount(int cacheId, int part)`
`<K,V> GridCloseableIterator<javax.cache.Cache.Entry<K,V>>` `cacheEntriesIterator(GridCacheContext cctx, boolean primary, boolean backup, AffinityTopologyVersion topVer, boolean keepBinary)`
`GridIterator<CacheDataRow>` `cacheIterator(int cacheId, boolean primary, boolean backups, AffinityTopologyVersion topVer)`
`GridCloseableIterator<KeyCacheObject>` `cacheKeysIterator(int cacheId, int part)`
`GridIterator<CacheDataRow>` `cachePartitionIterator(int cacheId, int part)`
`void` `clearCache(GridCacheContext cctx, boolean readers)` Clears offheap entries.
`boolean` `containsKey(GridCacheMapEntry entry)` TODO: GG-10884, used on only from initialValue.
`IgniteCacheOffheapManager.CacheDataStore` `createCacheDataStore(int p)`
`protected IgniteCacheOffheapManager.CacheDataStore` `createCacheDataStore0(int p)`
`IgniteCacheOffheapManager.CacheDataStore` `dataStore(GridDhtLocalPartition part)`
`void` `destroyCacheDataStore(IgniteCacheOffheapManager.CacheDataStore store)`
`protected void` `destroyCacheDataStore0(IgniteCacheOffheapManager.CacheDataStore store)`
`void` `dropRootPageForIndex(int cacheId, String idxName)`
`boolean` `expire(GridCacheContext cctx, IgniteInClosure2X<GridCacheEntryEx,GridCacheVersion> c, int amount)`
`long` `expiredSize()` Gets the number of entries pending expire.
`GridAtomicLong` `globalRemoveId()`
`protected void` `initDataStructures()`
`void` `invoke(GridCacheContext cctx, KeyCacheObject key, GridDhtLocalPartition part, IgniteCacheOffheapManager.OffheapInvokeClosure c)`
`long` `lastUpdatedPartitionCounter(int part)` Partition counter provider.
`long` `offHeapAllocatedSize()`
`void` `onCacheStarted(GridCacheContext cctx)`
`void` `onKernalStop()`
`void` `onPartitionCounterUpdated(int part, long cntr)` Partition counter update callback.
`void` `onPartitionInitialCounterUpdated(int part, long cntr)` Initial counter will be updated on state restore only
`int` `onUndeploy(ClassLoader ldr)`
`GridIterator<CacheDataRow>` `partitionIterator(int part)`
`CacheDataRow` `read(GridCacheContext cctx, KeyCacheObject key)`
`CacheDataRow` `read(GridCacheMapEntry entry)`
`IgniteRebalanceIterator` `rebalanceIterator(int part, AffinityTopologyVersion topVer, Long partCntr)`
`void` `remove(GridCacheContext cctx, KeyCacheObject key, int partId, GridDhtLocalPartition part)`
`ReuseList` `reuseListForIndex(String idxName)`
`RootPage` `rootPageForIndex(int cacheId, String idxName)`
`void` `start(GridCacheSharedContext ctx, CacheGroupContext grp)`
`void` `stop()`
`void` `stopCache(int cacheId, boolean destroy)`
`int` `totalPartitionEntriesCount(int p)`
`protected String` `treeName(int p)`
`void` `update(GridCacheContext cctx, KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime, GridDhtLocalPartition part, CacheDataRow oldRow)`
`void` `updateIndexes(GridCacheContext cctx, KeyCacheObject key, GridDhtLocalPartition part)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### ctx

    protected GridCacheSharedContext ctx

#### grp

    protected CacheGroupContext grp

#### log

    protected IgniteLogger log

#### partDataStores

    protected final ConcurrentMap<Integer,IgniteCacheOffheapManager.CacheDataStore> partDataStores

#### pendingEntries

    protected IgniteCacheOffheapManagerImpl.PendingEntriesTree pendingEntries

### Constructor Detail

#### IgniteCacheOffheapManagerImpl

    public IgniteCacheOffheapManagerImpl()

### Method Detail

#### globalRemoveId

    public GridAtomicLong globalRemoveId()

Specified by:
  `globalRemoveId` in interface `IgniteCacheOffheapManager`
Returns:
  Global remove ID counter.

#### start

    public void start(GridCacheSharedContext ctx,
             CacheGroupContext grp)
               throws IgniteCheckedException

Specified by:
  `start` in interface `IgniteCacheOffheapManager`
Parameters:
  `ctx` - Context.
  `grp` - Cache group.
Throws:
  `IgniteCheckedException` - If failed.

#### onCacheStarted

    public void onCacheStarted(GridCacheContext cctx)
                        throws IgniteCheckedException

Specified by:
  `onCacheStarted` in interface `IgniteCacheOffheapManager`
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:
  `stopCache` in interface `IgniteCacheOffheapManager`
Parameters:
  `cacheId` - Cache ID.
  `destroy` - Destroy data flag.

#### stop

    public void stop()

Specified by:
  `stop` in interface `IgniteCacheOffheapManager`

#### onKernalStop

    public void onKernalStop()

Specified by:
  `onKernalStop` in interface `IgniteCacheOffheapManager`

#### dataStore

    public IgniteCacheOffheapManager.CacheDataStore dataStore(GridDhtLocalPartition part)

Specified by:
  `dataStore` in interface `IgniteCacheOffheapManager`
Parameters:
  `part` - Partition.
Returns:
  Data store for given entry.

#### cacheEntriesCount

    public long cacheEntriesCount(int cacheId)

Specified by:
  `cacheEntriesCount` in interface `IgniteCacheOffheapManager`
Parameters:
  `cacheId` - Cache ID.
Returns:
  Number of entries.

#### totalPartitionEntriesCount

    public int totalPartitionEntriesCount(int p)

Specified by:
  `totalPartitionEntriesCount` in interface `IgniteCacheOffheapManager`
Parameters:
  `p` - Partition.
Returns:
  Number of entries.

#### cacheEntriesCount

    public long cacheEntriesCount(int cacheId,
                         boolean primary,
                         boolean backup,
                         AffinityTopologyVersion topVer)
                           throws IgniteCheckedException

Specified by:
  `cacheEntriesCount` in interface `IgniteCacheOffheapManager`
Parameters:
  `cacheId` - Cache ID.
  `primary` - Primary entries flag.
  `backup` - Backup entries flag.
  `topVer` - Topology version.
Returns:
  Entries count.
Throws:
  `IgniteCheckedException` - If failed.

#### cacheEntriesCount

    public long cacheEntriesCount(int cacheId,
                         int part)

Specified by:
  `cacheEntriesCount` in interface `IgniteCacheOffheapManager`
Parameters:
  `cacheId` - Cache ID.
  `part` - Partition.
Returns:
  Number of entries in given partition.

#### invoke

    public void invoke(GridCacheContext cctx,
              KeyCacheObject key,
              GridDhtLocalPartition part,
              IgniteCacheOffheapManager.OffheapInvokeClosure c)
                throws IgniteCheckedException

Specified by:
  `invoke` in interface `IgniteCacheOffheapManager`
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
              CacheDataRow oldRow)
                throws IgniteCheckedException

Specified by:
  `update` in interface `IgniteCacheOffheapManager`
Parameters:
  `cctx` - Cache context.
  `key` - Key.
  `val` - Value.
  `ver` - Version.
  `expireTime` - Expire time.
  `part` - Partition.
  `oldRow` - Old row if available.
Throws:
  `IgniteCheckedException` - If failed.

#### updateIndexes

    public void updateIndexes(GridCacheContext cctx,
                     KeyCacheObject key,
                     GridDhtLocalPartition part)
                       throws IgniteCheckedException

Specified by:
  `updateIndexes` in interface `IgniteCacheOffheapManager`
Parameters:
  `cctx` - Cache context.
  `key` - Key.
  `part` - Partition.
Throws:
  `IgniteCheckedException` - If failed.

#### remove

    public void remove(GridCacheContext cctx,
              KeyCacheObject key,
              int partId,
              GridDhtLocalPartition part)
                throws IgniteCheckedException

Specified by:
  `remove` in interface `IgniteCacheOffheapManager`
Parameters:
  `cctx` - Cache context.
  `key` - Key.
  `partId` - Partition number.
  `part` - Partition.
Throws:
  `IgniteCheckedException` - If failed.

#### read

    @Nullable
    public CacheDataRow read(GridCacheMapEntry entry)
                      throws IgniteCheckedException

Specified by:
  `read` in interface `IgniteCacheOffheapManager`
Parameters:
  `entry` - Cache entry.
Returns:
  Cached row, if available, null otherwise.
Throws:
  `IgniteCheckedException` - If failed.

#### read

    @Nullable
    public CacheDataRow read(GridCacheContext cctx,
                             KeyCacheObject key)
                      throws IgniteCheckedException

Specified by:
  `read` in interface `IgniteCacheOffheapManager`
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:
  `containsKey` in interface `IgniteCacheOffheapManager`

#### onPartitionCounterUpdated

    public void onPartitionCounterUpdated(int part,
                                 long cntr)

Partition counter update callback. May be overridden by plugin-provided subclasses.

Specified by:
  `onPartitionCounterUpdated` in interface `IgniteCacheOffheapManager`
Parameters:
  `part` - Partition.
  `cntr` - Partition counter.

#### onPartitionInitialCounterUpdated

    public void onPartitionInitialCounterUpdated(int part,
                                        long cntr)

Initial counter will be updated on state restore only

Specified by:
  `onPartitionInitialCounterUpdated` in interface `IgniteCacheOffheapManager`
Parameters:
  `part` - Partition
  `cntr` - New initial counter

#### lastUpdatedPartitionCounter

    public long lastUpdatedPartitionCounter(int part)

Partition counter provider. May be overridden by plugin-provided subclasses.

Specified by:
  `lastUpdatedPartitionCounter` in interface `IgniteCacheOffheapManager`
Parameters:
  `part` - Partition ID.
Returns:
  Last updated counter.

#### clearCache

    public void clearCache(GridCacheContext cctx,
                  boolean readers)

Clears offheap entries.

Specified by:
  `clearCache` in interface `IgniteCacheOffheapManager`
Parameters:
  `readers` - `True` to clear readers.
  `cctx` - Cache context.

#### onUndeploy

    public int onUndeploy(ClassLoader ldr)

Specified by:
  `onUndeploy` in interface `IgniteCacheOffheapManager`
Parameters:
  `ldr` - Class loader.
Returns:
  Number of undeployed entries.

#### offHeapAllocatedSize

    public long offHeapAllocatedSize()

Specified by:
  `offHeapAllocatedSize` in interface `IgniteCacheOffheapManager`
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)
                                                                             throws IgniteCheckedException

Specified by:
  `cacheEntriesIterator` in interface `IgniteCacheOffheapManager`
Parameters:
  `primary` - `True` if need return primary entries.
  `backup` - `True` if need return backup entries.
  `topVer` - Topology version to use.
  `cctx` - Cache context.
  `keepBinary` - Keep binary flag.
Returns:
  Entries iterator.
Throws:
  `IgniteCheckedException` - If failed.

#### cacheKeysIterator

    public GridCloseableIterator<KeyCacheObject> cacheKeysIterator(int cacheId,
                                                          int part)
                                                            throws IgniteCheckedException

Specified by:
  `cacheKeysIterator` in interface `IgniteCacheOffheapManager`
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)
                                             throws IgniteCheckedException

Specified by:
  `cacheIterator` in interface `IgniteCacheOffheapManager`
Parameters:
  `cacheId` - Cache ID.
  `primary` - Primary entries flag.
  `backups` - Backup entries flag.
  `topVer` - Topology version.
Returns:
  Rows iterator.
Throws:
  `IgniteCheckedException` - If failed.

#### cachePartitionIterator

    public GridIterator<CacheDataRow> cachePartitionIterator(int cacheId,
                                                    int part)
                                                      throws IgniteCheckedException

Specified by:
  `cachePartitionIterator` in interface `IgniteCacheOffheapManager`
Parameters:
  `cacheId` - Cache ID.
  `part` - Partition.
Returns:
  Partition data iterator.
Throws:
  `IgniteCheckedException` - If failed.

#### partitionIterator

    public GridIterator<CacheDataRow> partitionIterator(int part)
                                                 throws IgniteCheckedException

Specified by:
  `partitionIterator` in interface `IgniteCacheOffheapManager`
Parameters:
  `part` - Partition number.
Returns:
  Iterator for given partition.
Throws:
  `IgniteCheckedException` - If failed.

#### rootPageForIndex

    public RootPage rootPageForIndex(int cacheId,
                            String idxName)
                              throws IgniteCheckedException

Specified by:
  `rootPageForIndex` in interface `IgniteCacheOffheapManager`
Parameters:
  `cacheId` - Cache ID.
  `idxName` - Index name.
Returns:
  Root page for index tree.
Throws:
  `IgniteCheckedException` - If failed.

#### dropRootPageForIndex

    public void dropRootPageForIndex(int cacheId,
                            String idxName)
                              throws IgniteCheckedException

Specified by:
  `dropRootPageForIndex` in interface `IgniteCacheOffheapManager`
Parameters:
  `cacheId` - Cache ID.
  `idxName` - Index name.
Throws:
  `IgniteCheckedException` - If failed.

#### reuseListForIndex

    public ReuseList reuseListForIndex(String idxName)

Specified by:
  `reuseListForIndex` in interface `IgniteCacheOffheapManager`
Parameters:
  `idxName` - Index name.
Returns:
  Reuse list for index tree.

#### rebalanceIterator

    public IgniteRebalanceIterator rebalanceIterator(int part,
                                            AffinityTopologyVersion topVer,
                                            Long partCntr)
                                              throws IgniteCheckedException

Specified by:
  `rebalanceIterator` in interface `IgniteCacheOffheapManager`
Parameters:
  `part` - Partition.
  `topVer` - Topology version.
  `partCntr` - Partition counter to get historical data if available.
Returns:
  Partition data iterator.
Throws:
  `IgniteCheckedException` - If failed.

#### createCacheDataStore

    public final IgniteCacheOffheapManager.CacheDataStore createCacheDataStore(int p)
                                                                        throws IgniteCheckedException

Specified by:
  `createCacheDataStore` in interface `IgniteCacheOffheapManager`
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.

#### cacheDataStores

    public Iterable<IgniteCacheOffheapManager.CacheDataStore> cacheDataStores()

Specified by:
  `cacheDataStores` in interface `IgniteCacheOffheapManager`
Returns:
  Iterable over all existing cache data stores.

#### destroyCacheDataStore

    public final void destroyCacheDataStore(IgniteCacheOffheapManager.CacheDataStore store)
                                     throws IgniteCheckedException

Specified by:
  `destroyCacheDataStore` in interface `IgniteCacheOffheapManager`
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:
  `expire` in interface `IgniteCacheOffheapManager`
Parameters:
  `cctx` - Cache context.
  `c` - Closure.
Throws:
  `IgniteCheckedException` - If failed.

#### expiredSize

    public long expiredSize()
                     throws IgniteCheckedException

Gets the number of entries pending expire.

Specified by:
  `expiredSize` in interface `IgniteCacheOffheapManager`
Returns:
  Number of pending entries.
Throws:
  `IgniteCheckedException` - If failed to get number of pending entries.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.2.0
Release Date | : September 15 2017