org.apache.ignite.internal.processors.cache

## Class CacheAffinitySharedManager<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter<K,V>
  - - org.apache.ignite.internal.processors.cache.CacheAffinitySharedManager<K,V>

All Implemented Interfaces:
  GridCacheSharedManager<K,V>

    public class CacheAffinitySharedManager<K,V>
    extends GridCacheSharedManagerAdapter<K,V>

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter

`cctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`CacheAffinitySharedManager()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addDhtAssignmentFetchFuture(GridDhtAssignmentFetchFuture fut)`
`GridAffinityAssignmentCache` `affinity(Integer grpId)`
`void` `applyAffinityFromFullMessage(GridDhtPartitionsExchangeFuture fut, GridDhtPartitionsFullMessage msg)` Applies affinity diff from the received full message.
`Map<Integer,CacheGroupDescriptor>` `cacheGroups()`
`Map<Integer,DynamicCacheDescriptor>` `caches()`
`void` `dumpDebugInfo()`
`GridAffinityAssignmentCache` `groupAffinity(int grpId)`
`IgniteInternalFuture<Map<Integer,Map<Integer,List<UUID>>>>` `initAffinityOnNodeLeft(GridDhtPartitionsExchangeFuture fut)`
`void` `initCachesOnLocalJoin(Map<Integer,CacheGroupDescriptor> cacheGroupDescriptors, Map<String,DynamicCacheDescriptor> cacheDescriptors)` Must be called from exchange thread.
`IgniteInternalFuture<?>` `initCoordinatorCaches(GridDhtPartitionsExchangeFuture fut, boolean newAff)`
`void` `initStartedCaches(boolean crd, GridDhtPartitionsExchangeFuture fut, Collection<DynamicCacheDescriptor> descs)` Initialized affinity for cache received from node joining on this exchange.
`void` `onBaselineTopologyChanged(GridDhtPartitionsExchangeFuture fut, boolean crd)`
`void` `onCacheChangeRequest(GridDhtPartitionsExchangeFuture fut, boolean crd, ExchangeActions exchActions)` Called on exchange initiated for cache start/stop request.
`boolean` `onCentralizedAffinityChange(GridDhtPartitionsExchangeFuture fut, boolean crd)` Called on exchange initiated by server node leave or custom event with centralized affinity assignment.
`void` `onChangeAffinityMessage(GridDhtPartitionsExchangeFuture exchFut, boolean crd, CacheAffinityChangeMessage msg)` Called on exchange initiated by `CacheAffinityChangeMessage` which sent after rebalance finished.
`void` `onClientEvent(GridDhtPartitionsExchangeFuture fut, boolean crd)` Called on exchange initiated by client node join/fail.
`Map<Integer,CacheGroupAffinityMessage>` `onCustomEventWithEnforcedAffinityReassignment(GridDhtPartitionsExchangeFuture fut)` Calculates affinity on coordinator for custom event types that require centralized assignment.
`void` `onCustomMessageNoAffinityChange(GridDhtPartitionsExchangeFuture fut, boolean crd, ExchangeActions exchActions)`
`void` `onExchangeChangeAffinityMessage(GridDhtPartitionsExchangeFuture exchFut, boolean crd, CacheAffinityChangeMessage msg)` Called when received `CacheAffinityChangeMessage` which should complete exchange.
`void` `onLocalJoin(GridDhtPartitionsExchangeFuture fut, GridDhtPartitionsFullMessage msg, AffinityTopologyVersion resTopVer)`
`void` `onServerJoin(GridDhtPartitionsExchangeFuture fut, boolean crd)` Called on exchange initiated by server node join.
`void` `onServerJoinWithExchangeMergeProtocol(GridDhtPartitionsExchangeFuture fut, boolean crd)`
`Map<Integer,CacheGroupAffinityMessage>` `onServerLeftWithExchangeMergeProtocol(GridDhtPartitionsExchangeFuture fut)`
`void` `removeAllCacheInfo()`
`void` `removeDhtAssignmentFetchFuture(GridDhtAssignmentFetchFuture fut)`
`protected void` `start0()`
`void` `stopCacheGroupOnReconnect(CacheGroupContext grpCtx)`
`void` `stopCacheOnReconnect(GridCacheContext cctx)`
`Set<Integer>` `waitGroups()`

### Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter

`context, isStopping, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStop, onKernalStop0, onReconnected, printMemoryStats, start, startInfo, stop, stop0, stopInfo, toString`

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

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

### Constructor Detail

#### CacheAffinitySharedManager

    public CacheAffinitySharedManager()

### Method Detail

#### start0

    protected void start0()
                   throws IgniteCheckedException

Overrides:
  `start0` in class `GridCacheSharedManagerAdapter<K,V>`
Throws:
  `IgniteCheckedException` - If failed.

#### initCachesOnLocalJoin

    public void initCachesOnLocalJoin(Map<Integer,CacheGroupDescriptor> cacheGroupDescriptors,
                                      Map<String,DynamicCacheDescriptor> cacheDescriptors)

Must be called from exchange thread.

#### waitGroups

    public Set<Integer> waitGroups()

Returns:
  Group IDs.

#### onCustomMessageNoAffinityChange

    public void onCustomMessageNoAffinityChange(GridDhtPartitionsExchangeFuture fut,
                                                boolean crd,
                                                @Nullable
                                                ExchangeActions exchActions)

Parameters:
  `fut` - Exchange future.
  `crd` - Coordinator flag.
  `exchActions` - Exchange actions.

#### stopCacheOnReconnect

    public void stopCacheOnReconnect(GridCacheContext cctx)

Parameters:
  `cctx` - Stopped cache context.

#### stopCacheGroupOnReconnect

    public void stopCacheGroupOnReconnect(CacheGroupContext grpCtx)

Parameters:
  `grpCtx` - Stopped cache group context.

#### onCacheChangeRequest

    public void onCacheChangeRequest(GridDhtPartitionsExchangeFuture fut,
                                     boolean crd,
                                     ExchangeActions exchActions)
                              throws IgniteCheckedException

Called on exchange initiated for cache start/stop request.

Parameters:
  `fut` - Exchange future.
  `crd` - Coordinator flag.
  `exchActions` - Cache change requests.
Throws:
  `IgniteCheckedException` - If failed.

#### removeAllCacheInfo

    public void removeAllCacheInfo()

#### onExchangeChangeAffinityMessage

    public void onExchangeChangeAffinityMessage(GridDhtPartitionsExchangeFuture exchFut,
                                                boolean crd,
                                                CacheAffinityChangeMessage msg)

Called when received `CacheAffinityChangeMessage` which should complete exchange.

Parameters:
  `exchFut` - Exchange future.
  `crd` - Coordinator flag.
  `msg` - Affinity change message.

#### onChangeAffinityMessage

    public void onChangeAffinityMessage(GridDhtPartitionsExchangeFuture exchFut,
                                        boolean crd,
                                        CacheAffinityChangeMessage msg)
                                 throws IgniteCheckedException

Called on exchange initiated by `CacheAffinityChangeMessage` which sent after rebalance finished.

Parameters:
  `exchFut` - Exchange future.
  `crd` - Coordinator flag.
  `msg` - Message.
Throws:
  `IgniteCheckedException` - If failed.

#### onClientEvent

    public void onClientEvent(GridDhtPartitionsExchangeFuture fut,
                              boolean crd)
                       throws IgniteCheckedException

Called on exchange initiated by client node join/fail.

Parameters:
  `fut` - Exchange future.
  `crd` - Coordinator flag.
Throws:
  `IgniteCheckedException` - If failed.

#### addDhtAssignmentFetchFuture

    public void addDhtAssignmentFetchFuture(GridDhtAssignmentFetchFuture fut)

Parameters:
  `fut` - Future to add.

#### removeDhtAssignmentFetchFuture

    public void removeDhtAssignmentFetchFuture(GridDhtAssignmentFetchFuture fut)

Parameters:
  `fut` - Future to remove.

#### initStartedCaches

    public void initStartedCaches(boolean crd,
                                  GridDhtPartitionsExchangeFuture fut,
                                  Collection<DynamicCacheDescriptor> descs)
                           throws IgniteCheckedException

Initialized affinity for cache received from node joining on this exchange.

Parameters:
  `crd` - Coordinator flag.
  `fut` - Exchange future.
  `descs` - Cache descriptors.
Throws:
  `IgniteCheckedException` - If failed.

#### affinity

    public GridAffinityAssignmentCache affinity(Integer grpId)

Parameters:
  `grpId` - Cache group ID.
Returns:
  Affinity assignments.

#### applyAffinityFromFullMessage

    public void applyAffinityFromFullMessage(GridDhtPartitionsExchangeFuture fut,
                                             GridDhtPartitionsFullMessage msg)

Applies affinity diff from the received full message.

Parameters:
  `fut` - Current exchange future.
  `msg` - Finish exchange message.

#### onLocalJoin

    public void onLocalJoin(GridDhtPartitionsExchangeFuture fut,
                            GridDhtPartitionsFullMessage msg,
                            AffinityTopologyVersion resTopVer)

Parameters:
  `fut` - Current exchange future.
  `msg` - Message finish message.
  `resTopVer` - Result topology version.

#### onServerJoinWithExchangeMergeProtocol

    public void onServerJoinWithExchangeMergeProtocol(GridDhtPartitionsExchangeFuture fut,
                                                      boolean crd)
                                               throws IgniteCheckedException

Parameters:
  `fut` - Current exchange future.
  `crd` - Coordinator flag.
Throws:
  `IgniteCheckedException` - If failed.

#### onServerLeftWithExchangeMergeProtocol

    public Map<Integer,CacheGroupAffinityMessage> onServerLeftWithExchangeMergeProtocol(GridDhtPartitionsExchangeFuture fut)
                                                                                 throws IgniteCheckedException

Parameters:
  `fut` - Current exchange future.
Returns:
  Computed difference with ideal affinity.
Throws:
  `IgniteCheckedException` - If failed.

#### onCustomEventWithEnforcedAffinityReassignment

    public Map<Integer,CacheGroupAffinityMessage> onCustomEventWithEnforcedAffinityReassignment(GridDhtPartitionsExchangeFuture fut)
                                                                                         throws IgniteCheckedException

Calculates affinity on coordinator for custom event types that require centralized assignment.

Parameters:
  `fut` - Current exchange future.
Returns:
  Computed difference with ideal affinity.
Throws:
  `IgniteCheckedException` - If failed.

#### onServerJoin

    public void onServerJoin(GridDhtPartitionsExchangeFuture fut,
                             boolean crd)
                      throws IgniteCheckedException

Called on exchange initiated by server node join.

Parameters:
  `fut` - Exchange future.
  `crd` - Coordinator flag.
Throws:
  `IgniteCheckedException` - If failed.

#### onBaselineTopologyChanged

    public void onBaselineTopologyChanged(GridDhtPartitionsExchangeFuture fut,
                                          boolean crd)
                                   throws IgniteCheckedException

Parameters:
  `fut` - Exchange future
  `crd` - Coordinator flag.
Throws:
  `IgniteCheckedException` - If failed.

#### onCentralizedAffinityChange

    public boolean onCentralizedAffinityChange(GridDhtPartitionsExchangeFuture fut,
                                               boolean crd)
                                        throws IgniteCheckedException

Called on exchange initiated by server node leave or custom event with centralized affinity assignment.

Parameters:
  `fut` - Exchange future.
  `crd` - Coordinator flag.
Returns:
  `True` if affinity should be assigned by coordinator.
Throws:
  `IgniteCheckedException` - If failed.

#### initCoordinatorCaches

    public IgniteInternalFuture<?> initCoordinatorCaches(GridDhtPartitionsExchangeFuture fut,
                                                         boolean newAff)
                                                  throws IgniteCheckedException

Parameters:
  `fut` - Exchange future.
  `newAff` - `True` if there are no older nodes with affinity info available.
Returns:
  Future completed when caches initialization is done.
Throws:
  `IgniteCheckedException` - If failed.

#### initAffinityOnNodeLeft

    public IgniteInternalFuture<Map<Integer,Map<Integer,List<UUID>>>> initAffinityOnNodeLeft(GridDhtPartitionsExchangeFuture fut)
                                                                                      throws IgniteCheckedException

Parameters:
  `fut` - Exchange future.
Returns:
  Affinity assignment.
Throws:
  `IgniteCheckedException` - If failed.

#### cacheGroups

    public Map<Integer,CacheGroupDescriptor> cacheGroups()

Returns:
  All registered cache groups.

#### caches

    public Map<Integer,DynamicCacheDescriptor> caches()

Returns:
  All registered cache groups.

#### groupAffinity

    @Nullable
    public GridAffinityAssignmentCache groupAffinity(int grpId)

Parameters:
  `grpId` - Cache group ID
Returns:
  Cache affinity cache.

#### dumpDebugInfo

    public void dumpDebugInfo()

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.5.0
Release Date | : May 23 2018