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 Modifier and Type Field Description static intDFLT_CLIENT_CACHE_CHANGE_MESSAGE_TIMEOUT-
Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter
cctx, diagnosticLog, log
-
-
Constructor Summary
Constructors Constructor Description CacheAffinitySharedManager()
-
Method Summary
-
Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter
context, isStopping, kernalStartInfo, kernalStopInfo, onDisconnected, onKernalStart, onKernalStart0, onKernalStop, onKernalStop0, onReconnected, printMemoryStats, start, startInfo, stop, stop0, stopInfo, toString
-
-
-
-
Method Detail
-
start0
protected void start0() throws IgniteCheckedException- Overrides:
start0in classGridCacheSharedManagerAdapter<K,V>- Throws:
IgniteCheckedException- If failed.
-
initCachesOnLocalJoin
public IgniteInternalFuture<?> initCachesOnLocalJoin(Map<Integer,CacheGroupDescriptor> grpDescs, Map<String,DynamicCacheDescriptor> cacheDescs)
Must be called from exchange thread.
-
waitRebalance
public boolean waitRebalance(int grpId, int partId)- Parameters:
grpId- Group id.partId- Partition id.- Returns:
Trueif this node waits for the partition rebalance.
-
rebalanceRequired
public boolean rebalanceRequired()
- Returns:
trueif rebalance expected.
-
addToWaitGroup
public void addToWaitGroup(int grpId, int part, AffinityTopologyVersion topVer, List<ClusterNode> assignment)Adds group partition to wait list.Late affinity switch will be triggered as soons as wait list becomes empty.
- Parameters:
grpId- Group id.part- Part.topVer- Topology version.assignment- Ideal assignment.
-
onCustomMessageNoAffinityChange
public void onCustomMessageNoAffinityChange(GridDhtPartitionsExchangeFuture fut, @Nullable @Nullable ExchangeActions exchActions)
- Parameters:
fut- Exchange future.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.
-
removeGroupHolders
public void removeGroupHolders()
Removes and unregisters all group holders. This method cannot be transformed toGridCacheSharedManagerAdapter.onDisconnected(IgniteFuture)becauseGridCachePartitionExchangeManagerrequires fully initialized cache group holders until it handles the disconnect event, and so, it must be called directly.
-
forceCloseCaches
public void forceCloseCaches(GridDhtPartitionsExchangeFuture fut, boolean crd, ExchangeActions exchActions)
Called during the rollback of the exchange partitions procedure in order to stop the given cache even if it's not fully initialized (e.g. failed on cache init stage).- Parameters:
fut- Exchange future.crd- Coordinator flag.exchActions- Cache change requests.
-
onCacheChangeRequest
public IgniteInternalFuture<?> 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.
-
clearGroupHoldersAndRegistry
public void clearGroupHoldersAndRegistry()
-
onExchangeChangeAffinityMessage
public void onExchangeChangeAffinityMessage(GridDhtPartitionsExchangeFuture exchFut, CacheAffinityChangeMessage msg)
Called when receivedCacheAffinityChangeMessagewhich should complete exchange.- Parameters:
exchFut- Exchange future.msg- Affinity change message.
-
onChangeAffinityMessage
public void onChangeAffinityMessage(GridDhtPartitionsExchangeFuture exchFut, CacheAffinityChangeMessage msg)
Called on exchange initiated byCacheAffinityChangeMessagewhich sent after rebalance finished.- Parameters:
exchFut- Exchange future.msg- Message.
-
onClientEvent
public void onClientEvent(GridDhtPartitionsExchangeFuture fut) throws IgniteCheckedException
Called on exchange initiated by client node join/fail.- Parameters:
fut- Exchange future.- 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 IgniteInternalFuture<?> 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, Map<Integer,CacheGroupAffinityMessage> idealAffDiff)
Applies affinity diff from the received full message.- Parameters:
fut- Current exchange future.idealAffDiff- Map [Cache group id - Affinity distribution] which contains difference with ideal affinity.
-
onLocalJoin
public Set<Integer> onLocalJoin(GridDhtPartitionsExchangeFuture fut, Map<Integer,CacheGroupAffinityMessage> receivedAff, AffinityTopologyVersion resTopVer)
- Parameters:
fut- Current exchange future.receivedAff- Map [Cache group id - Affinity distribution] received from coordinator to apply.resTopVer- Result topology version.- Returns:
- Set of cache groups with no affinity localed in given
receivedAff.
-
onServerJoinWithExchangeMergeProtocol
public void onServerJoinWithExchangeMergeProtocol(GridDhtPartitionsExchangeFuture fut, boolean crd)
- Parameters:
fut- Current exchange future.crd- Coordinator flag.
-
onServerLeftWithExchangeMergeProtocol
public Map<Integer,CacheGroupAffinityMessage> onServerLeftWithExchangeMergeProtocol(GridDhtPartitionsExchangeFuture fut)
- Parameters:
fut- Current exchange future.- Returns:
- Computed difference with ideal affinity.
-
onExchangeFreeSwitch
public void onExchangeFreeSwitch(GridDhtPartitionsExchangeFuture fut)
Called on exchange initiated by baseline server node leave on fully-rebalanced topology.- Parameters:
fut- Exchange future.
-
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.
-
onReassignmentEnforced
public Map<Integer,CacheGroupAffinityMessage> onReassignmentEnforced(GridDhtPartitionsExchangeFuture fut)
Calculates new affinity assignment on coordinator and creates affinity diff messages for other nodes.- Parameters:
fut- Current exchange future.- Returns:
- Computed difference with ideal affinity.
-
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)
- Parameters:
fut- Exchange futurecrd- Coordinator flag.
-
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:
Trueif 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-Trueif 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 @Nullable GridAffinityAssignmentCache groupAffinity(int grpId)
- Parameters:
grpId- Cache group ID- Returns:
- Cache affinity cache.
-
dumpDebugInfo
public void dumpDebugInfo()
-
-