Package org.apache.ignite.internal.processors.cache

## Class CacheGroupContext

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.CacheGroupContext

    public class CacheGroupContext
    extends Object

### Constructor Summary

Constructors
`CacheGroupContext​(GridCacheSharedContext<?,​?> ctx, int grpId, UUID rcvdFrom, CacheType cacheType, CacheConfiguration<?,​?> ccfg, boolean affNode, DataRegion dataRegion, CacheObjectContext cacheObjCtx, FreeList<?> freeList, ReuseList reuseList, AffinityTopologyVersion locStartVer, boolean persistenceEnabled, boolean walEnabled, boolean recoveryMode, CompressionHandler compressHnd)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addCacheEvent​(int part, KeyCacheObject key, UUID evtNodeId, int type, @Nullable CacheObject newVal, boolean hasNewVal, @Nullable CacheObject oldVal, boolean hasOldVal, boolean keepBinary)`
`void` `addCacheWithContinuousQuery​(GridCacheContext<?,​?> cctx)`
`void` `addRebalanceEvent​(int part, int type, ClusterNode discoNode, int discoType, long discoTs)` Adds rebalancing event.
`void` `addRebalanceMissEvent​(int part)` Adds partition supply event.
`void` `addRebalanceSupplyEvent​(int part)` Adds partition supply event.
`void` `addUnloadEvent​(int part)` Adds partition unload event.
`GridAffinityAssignmentCache` `affinity()`
`AffinityFunction` `affinityFunction()`
`boolean` `affinityNode()`
`Set<Integer>` `cacheIds()`
`CacheObjectContext` `cacheObjectContext()`
`String` `cacheOrGroupName()`
`List<GridCacheContext<?,​?>>` `caches()`
`boolean` `cdcEnabled()`
`CompressionHandler` `compressionHandler()`
`CacheConfiguration<?,​?>` `config()`
`DataRegion` `dataRegion()`
`boolean` `deploymentEnabled()`
`boolean` `eventRecordable​(int type)`
`void` `finishRecovery​(AffinityTopologyVersion startVer, UUID originalReceivedFrom, boolean affinityNode)` Finishes recovery for current cache group.
`FreeList<?>` `freeList()`
`boolean` `globalWalEnabled()`
`void` `globalWalEnabled​(boolean enabled)`
`int` `groupId()`
`boolean` `hasAtomicCaches()`
`boolean` `hasCache​(String cacheName)`
`boolean` `hasCaches()`
`boolean` `indexWalEnabled()`
`void` `indexWalEnabled​(boolean idxWalEnabled)`
`byte` `ioPolicy()`
`boolean` `isDrEnabled()`
`boolean` `isPreparedToStop()`
`boolean` `isRecoveryMode()`
`boolean` `isReplicated()`
`boolean` `isTopologyLocked()`
`ReadWriteLock` `listenerLock()` Obtain the group listeners lock.
`AffinityTopologyVersion` `localStartVersion()`
`boolean` `localWalEnabled()` Local WAL enabled flag.
`void` `localWalEnabled​(boolean enabled, boolean persist)`
`boolean` `logDataRecords()`
`CacheGroupMetricsImpl` `metrics()`
`@Nullable String` `name()`
`IgnitePredicate<ClusterNode>` `nodeFilter()`
`IgniteCacheOffheapManager` `offheap()`
`void` `onDisconnected​(IgniteFuture reconnectFut)`
`void` `onKernalStop()`
`void` `onPartitionCounterUpdate​(int cacheId, int part, long cntr, AffinityTopologyVersion topVer, boolean primary)`
`void` `onPartitionEvicted​(int part)`
`void` `onReconnected()`
`boolean` `persistenceEnabled()`
`GridCachePreloader` `preloader()`
`void` `prepareToStop()` Prepare cache to stop (prohibit any futher updates).
`boolean` `queriesEnabled()`
`boolean` `rebalanceEnabled()`
`UUID` `receivedFrom()`
`void` `removeCacheWithContinuousQuery​(GridCacheContext<?,​?> cctx)`
`void` `removeIOStatistic​(boolean destroy)` Removes statistics metrics registries.
`ReuseList` `reuseList()`
`GridCacheSharedContext<?,​?>` `shared()`
`boolean` `sharedGroup()`
`GridCacheContext<?,​?>` `singleCacheContext()`
`void` `start()`
`IoStatisticsHolder` `statisticsHolderData()`
`IoStatisticsHolder` `statisticsHolderIdx()`
`boolean` `storeCacheIdInDataPage()`
`boolean` `systemCache()`
`GridDhtPartitionTopology` `topology()`
`Collection<TopologyValidator>` `topologyValidators()`
`String` `toString()`
`void` `unwindUndeploys()`
`boolean` `userCache()`
`IgniteWriteAheadLogManager` `wal()`
`boolean` `walEnabled()` Value returned by this method can be changed runtime by the user or during rebalance.

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

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

### Constructor Detail

#### CacheGroupContext

    public CacheGroupContext​(GridCacheSharedContext<?,​?> ctx,
                             int grpId,
                             UUID rcvdFrom,
                             CacheType cacheType,
                             CacheConfiguration<?,​?> ccfg,
                             boolean affNode,
                             DataRegion dataRegion,
                             CacheObjectContext cacheObjCtx,
                             FreeList<?> freeList,
                             ReuseList reuseList,
                             AffinityTopologyVersion locStartVer,
                             boolean persistenceEnabled,
                             boolean walEnabled,
                             boolean recoveryMode,
                             CompressionHandler compressHnd)

Parameters:
  `ctx` - Context.
  `grpId` - Group ID.
  `rcvdFrom` - Node ID cache group was received from.
  `cacheType` - Cache type.
  `ccfg` - Cache configuration.
  `affNode` - Affinity node flag.
  `dataRegion` - data region.
  `cacheObjCtx` - Cache object context.
  `freeList` - Free list.
  `reuseList` - Reuse list.
  `locStartVer` - Topology version when group was started on local node.
  `persistenceEnabled` - Persistence enabled flag.
  `walEnabled` - Wal enabled flag.
  `compressHnd` - Compression handler.

### Method Detail

#### systemCache

    public boolean systemCache()

Returns:
  `True` if this is cache group for one of system caches.

#### receivedFrom

    public UUID receivedFrom()

Returns:
  Node ID initiated cache group start.

#### storeCacheIdInDataPage

    public boolean storeCacheIdInDataPage()

Returns:
  `True` if cacheId should be stored in data pages.

#### deploymentEnabled

    public boolean deploymentEnabled()

Returns:
  `True` if deployment is enabled.

#### preloader

    public GridCachePreloader preloader()

Returns:
  Preloader.

#### ioPolicy

    public byte ioPolicy()

Returns:
  IO policy for the given cache group.

#### hasCache

    public boolean hasCache​(String cacheName)

Parameters:
  `cacheName` - Cache name.
Returns:
  `True` if group contains cache with given name.

#### singleCacheContext

    public GridCacheContext<?,​?> singleCacheContext()

Returns:
  Cache context if group contains single cache.

#### unwindUndeploys

    public void unwindUndeploys()

#### eventRecordable

    public boolean eventRecordable​(int type)

Parameters:
  `type` - Event type to check.
Returns:
  `True` if given event type should be recorded.

#### userCache

    public boolean userCache()

Returns:
  `True` if cache created by user.

#### addRebalanceEvent

    public void addRebalanceEvent​(int part,
                                  int type,
                                  ClusterNode discoNode,
                                  int discoType,
                                  long discoTs)

Adds rebalancing event.

Parameters:
  `part` - Partition.
  `type` - Event type.
  `discoNode` - Discovery node.
  `discoType` - Discovery event type.
  `discoTs` - Discovery event timestamp.

#### addUnloadEvent

    public void addUnloadEvent​(int part)

Adds partition unload event.

Parameters:
  `part` - Partition.

#### addRebalanceSupplyEvent

    public void addRebalanceSupplyEvent​(int part)

Adds partition supply event.

Parameters:
  `part` - Partition.

#### addRebalanceMissEvent

    public void addRebalanceMissEvent​(int part)

Adds partition supply event.

Parameters:
  `part` - Partition.

#### addCacheEvent

    public void addCacheEvent​(int part,
                              KeyCacheObject key,
                              UUID evtNodeId,
                              int type,
                              @Nullable
                              @Nullable CacheObject newVal,
                              boolean hasNewVal,
                              @Nullable
                              @Nullable CacheObject oldVal,
                              boolean hasOldVal,
                              boolean keepBinary)

Parameters:
  `part` - Partition.
  `key` - Key.
  `evtNodeId` - Event node ID.
  `type` - Event type.
  `newVal` - New value.
  `hasNewVal` - Has new value flag.
  `oldVal` - Old values.
  `hasOldVal` - Has old value flag.
  `keepBinary` - Keep binary flag.

#### queriesEnabled

    public boolean queriesEnabled()

Returns:
  `True` if contains cache with query indexing enabled.

#### isDrEnabled

    public boolean isDrEnabled()

Returns:
  `True` in case replication is enabled.

#### freeList

    public FreeList<?> freeList()

Returns:
  Free List.

#### reuseList

    public ReuseList reuseList()

Returns:
  Reuse List.

#### cacheObjectContext

    public CacheObjectContext cacheObjectContext()

Returns:
  Cache object context.

#### shared

    public GridCacheSharedContext<?,​?> shared()

Returns:
  Cache shared context.

#### dataRegion

    public DataRegion dataRegion()

Returns:
  data region.

#### affinityNode

    public boolean affinityNode()

Returns:
  `True` if local node is affinity node.

#### topology

    public GridDhtPartitionTopology topology()

Returns:
  Topology.

#### isTopologyLocked

    public boolean isTopologyLocked()

Returns:
  `True` if current thread holds lock on topology.

#### offheap

    public IgniteCacheOffheapManager offheap()

Returns:
  Offheap manager.

#### localStartVersion

    public AffinityTopologyVersion localStartVersion()

Returns:
  Topology version when group was started on local node.

#### isReplicated

    public boolean isReplicated()

Returns:
  `True` if cache is local.

#### config

    public CacheConfiguration<?,​?> config()

Returns:
  Cache configuration.

#### nodeFilter

    public IgnitePredicate<ClusterNode> nodeFilter()

Returns:
  Cache node filter.

#### topologyValidators

    public Collection<TopologyValidator> topologyValidators()

Returns:
  Configured topology validators.

#### affinityFunction

    public AffinityFunction affinityFunction()

Returns:
  Configured affinity function.

#### affinity

    public GridAffinityAssignmentCache affinity()

Returns:
  Affinity.

#### name

    @Nullable
    public @Nullable String name()

Returns:
  Group name or `null` if group name was not specified for cache.

#### cacheOrGroupName

    public String cacheOrGroupName()

Returns:
  Group name if it is specified, otherwise cache name.

#### groupId

    public int groupId()

Returns:
  Group ID.

#### sharedGroup

    public boolean sharedGroup()

Returns:
  `True` if group can contain multiple caches.

#### onKernalStop

    public void onKernalStop()

#### finishRecovery

    public void finishRecovery​(AffinityTopologyVersion startVer,
                               UUID originalReceivedFrom,
                               boolean affinityNode)
                        throws IgniteCheckedException

Finishes recovery for current cache group. Attaches topology version and initializes I/O.

Parameters:
  `startVer` - Cache group start version.
  `originalReceivedFrom` - UUID of node that was first who initiated cache group creating. This is needed to decide should node calculate affinity locally or fetch from other nodes.
  `affinityNode` - Flag indicates, is local node affinity node or not. This may be calculated only after node joined to topology.
Throws:
  `IgniteCheckedException` - If failed.

#### isRecoveryMode

    public boolean isRecoveryMode()

Returns:
  `True` if current cache group is in recovery mode.

#### cacheIds

    public Set<Integer> cacheIds()

Returns:
  IDs of caches in this group.

#### caches

    public List<GridCacheContext<?,​?>> caches()

Returns:
  Caches in this group. caches is already Unmodifiable list, so we don't need to explicitly wrap it here.

#### hasCaches

    public boolean hasCaches()

Returns:
  `True` if group contains caches.

#### onPartitionEvicted

    public void onPartitionEvicted​(int part)

Parameters:
  `part` - Partition ID.

#### addCacheWithContinuousQuery

    public void addCacheWithContinuousQuery​(GridCacheContext<?,​?> cctx)

Parameters:
  `cctx` - Cache context.

#### removeCacheWithContinuousQuery

    public void removeCacheWithContinuousQuery​(GridCacheContext<?,​?> cctx)

Parameters:
  `cctx` - Cache context.

#### listenerLock

    public ReadWriteLock listenerLock()

Obtain the group listeners lock. Write lock should be held to register/unregister listeners. Read lock should be hel for CQ listeners notification.

Returns:
  Lock for the CQ listeners.

#### onPartitionCounterUpdate

    public void onPartitionCounterUpdate​(int cacheId,
                                         int part,
                                         long cntr,
                                         AffinityTopologyVersion topVer,
                                         boolean primary)

Parameters:
  `cacheId` - ID of cache initiated counter update.
  `part` - Partition number.
  `cntr` - Counter.
  `topVer` - Topology version for current operation.

#### start

    public void start()
               throws IgniteCheckedException

Throws:
  `IgniteCheckedException` - If failed.

#### persistenceEnabled

    public boolean persistenceEnabled()

Returns:
  Persistence enabled flag.

#### logDataRecords

    public boolean logDataRecords()

Returns:
  `True` if `DataRecord` should be loged in the WAL.

#### cdcEnabled

    public boolean cdcEnabled()

Returns:
  `True` if CDC enabled.

#### onDisconnected

    public void onDisconnected​(IgniteFuture reconnectFut)

Parameters:
  `reconnectFut` - Reconnect future.

#### rebalanceEnabled

    public boolean rebalanceEnabled()

Returns:
  `True` if rebalance is enabled.

#### onReconnected

    public void onReconnected()

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### walEnabled

    public boolean walEnabled()

Value returned by this method can be changed runtime by the user or during rebalance.

Returns:
  WAL enabled flag.
See Also:
  `IgniteCluster.disableWal(String)`, `IgniteCluster.enableWal(String)`

#### localWalEnabled

    public boolean localWalEnabled()

Local WAL enabled flag.

Returns:
  `False` if a durability (WAL logging) is disabled for a group until rebalancing has finished.

#### globalWalEnabled

    public boolean globalWalEnabled()

Returns:
  Global WAL enabled flag.

#### indexWalEnabled

    public boolean indexWalEnabled()

Returns:
  `True` if WAL for index operations enabled.

#### indexWalEnabled

    public void indexWalEnabled​(boolean idxWalEnabled)

Parameters:
  `idxWalEnabled` - Index WAL enabled flag.

#### globalWalEnabled

    public void globalWalEnabled​(boolean enabled)

Parameters:
  `enabled` - Global WAL enabled flag.

#### localWalEnabled

    public void localWalEnabled​(boolean enabled,
                                boolean persist)

Parameters:
  `enabled` - Local WAL enabled flag.
  `persist` - If `true` then flag state will be persisted into metastorage.

#### statisticsHolderIdx

    public IoStatisticsHolder statisticsHolderIdx()

Returns:
  Statistics holder to track cache IO operations.

#### statisticsHolderData

    public IoStatisticsHolder statisticsHolderData()

Returns:
  Statistics holder to track cache IO operations.

#### hasAtomicCaches

    public boolean hasAtomicCaches()

Returns:
  `True` if group has atomic caches.

#### metrics

    public CacheGroupMetricsImpl metrics()

Returns:
  Metrics.

#### removeIOStatistic

    public void removeIOStatistic​(boolean destroy)

Removes statistics metrics registries.

Parameters:
  `destroy` - Group destroy flag.

#### wal

    public IgniteWriteAheadLogManager wal()

Returns:
  Write ahead log manager.

#### compressionHandler

    public CompressionHandler compressionHandler()

#### prepareToStop

    public void prepareToStop()

Prepare cache to stop (prohibit any futher updates).

#### isPreparedToStop

    public boolean isPreparedToStop()