Class GridAffinityProcessor
- java.lang.Object
-
- org.apache.ignite.internal.processors.GridProcessorAdapter
-
- org.apache.ignite.internal.processors.affinity.GridAffinityProcessor
-
- All Implemented Interfaces:
GridComponent,GridProcessor
public class GridAffinityProcessor extends GridProcessorAdapter
Data affinity processor.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent
GridComponent.DiscoveryDataExchangeType
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
ctx, diagnosticLog
-
-
Constructor Summary
Constructors Constructor Description GridAffinityProcessor(GridKernalContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IgniteInternalFuture<org.apache.ignite.internal.processors.affinity.GridAffinityProcessor.AffinityInfo>affinityCacheFuture(String cacheName, @Nullable AffinityTopologyVersion topVer)@Nullable ObjectaffinityKey(String cacheName, @Nullable Object key)Gets affinity key for cache key.<K> org.apache.ignite.internal.processors.affinity.GridAffinityProcessor.CacheAffinityProxy<K>affinityProxy(String cacheName)<K> Map<ClusterNode,Collection<K>>mapKeysToNodes(String cacheName, @Nullable Collection<? extends K> keys)Maps keys to nodes for given cache.<K> @Nullable ClusterNodemapKeyToNode(String cacheName, K key)Maps single key to a node.<K> @Nullable ClusterNodemapKeyToNode(String cacheName, K key, AffinityTopologyVersion topVer)Maps single key to a node.<K> List<ClusterNode>mapKeyToPrimaryAndBackups(String cacheName, K key, AffinityTopologyVersion topVer)Map single key to primary and backup nodes.@Nullable ClusterNodemapPartitionToNode(String cacheName, int partId, AffinityTopologyVersion topVer)Maps partition to a node.voidonDisconnected(IgniteFuture<?> reconnectFut)Client disconnected callback.voidonKernalStop(boolean cancel)Callback to notify that kernal is about to stop.intpartition(String cacheName, Object key)intpartition(String cacheName, Object key, @Nullable org.apache.ignite.internal.processors.affinity.GridAffinityProcessor.AffinityInfo aff)intpartition0(String cacheName, Object key, @Nullable org.apache.ignite.internal.processors.affinity.GridAffinityProcessor.AffinityInfo aff)voidprintMemoryStats()Prints memory statistics (sizes of internal structures, etc.).voidremoveCachedAffinity(AffinityTopologyVersion topVer)Removes cached affinity instances with affinity topology versions less thantopVer.ObjectsimilaryAffinityKey(AffinityFunction aff, IgnitePredicate<ClusterNode> nodeFilter, int backups, int parts)voidstart()Starts grid component.-
Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
assertParameter, collectGridNodeData, collectJoiningNodeData, discoveryDataType, onGridDataReceived, onJoiningNodeDataReceived, onKernalStart, onReconnected, stop, toString, validateNode, validateNode
-
-
-
-
Constructor Detail
-
GridAffinityProcessor
public GridAffinityProcessor(GridKernalContext ctx)
- Parameters:
ctx- Context.
-
-
Method Detail
-
start
public void start() throws IgniteCheckedExceptionStarts grid component.- Specified by:
startin interfaceGridComponent- Overrides:
startin classGridProcessorAdapter- Throws:
IgniteCheckedException- Throws in case of any errors.
-
onKernalStop
public void onKernalStop(boolean cancel)
Callback to notify that kernal is about to stop.- Specified by:
onKernalStopin interfaceGridComponent- Overrides:
onKernalStopin classGridProcessorAdapter- Parameters:
cancel- Flag indicating whether jobs should be canceled.
-
onDisconnected
public void onDisconnected(IgniteFuture<?> reconnectFut) throws IgniteCheckedException
Client disconnected callback.- Specified by:
onDisconnectedin interfaceGridComponent- Overrides:
onDisconnectedin classGridProcessorAdapter- Parameters:
reconnectFut- Reconnect future.- Throws:
IgniteCheckedException- If failed.
-
partition
public int partition(String cacheName, Object key) throws IgniteCheckedException
- Parameters:
cacheName- Cache name.key- Key.- Returns:
- Key partition.
- Throws:
IgniteCheckedException- If failed.
-
partition
public int partition(String cacheName, Object key, @Nullable @Nullable org.apache.ignite.internal.processors.affinity.GridAffinityProcessor.AffinityInfo aff) throws IgniteCheckedException
- Parameters:
cacheName- Cache name (needed only ifaffis not provided.key- Key.aff- Affinity information.- Returns:
- Key partition.
- Throws:
IgniteCheckedException- If failed.
-
partition0
public int partition0(String cacheName, Object key, @Nullable @Nullable org.apache.ignite.internal.processors.affinity.GridAffinityProcessor.AffinityInfo aff) throws IgniteCheckedException
- Parameters:
cacheName- Cache name (needed only ifaffis not provided.key- Key.aff- Affinity.- Returns:
- Key partition.
- Throws:
IgniteCheckedException- If failed.
-
mapPartitionToNode
@Nullable public @Nullable ClusterNode mapPartitionToNode(String cacheName, int partId, AffinityTopologyVersion topVer) throws IgniteCheckedException
Maps partition to a node.- Parameters:
cacheName- Cache name.partId- partition.topVer- Affinity topology version.- Returns:
- Picked node.
- Throws:
IgniteCheckedException- If failed.
-
removeCachedAffinity
public void removeCachedAffinity(AffinityTopologyVersion topVer)
Removes cached affinity instances with affinity topology versions less thantopVer.- Parameters:
topVer- topology version.
-
mapKeysToNodes
public <K> Map<ClusterNode,Collection<K>> mapKeysToNodes(String cacheName, @Nullable @Nullable Collection<? extends K> keys) throws IgniteCheckedException
Maps keys to nodes for given cache.- Parameters:
cacheName- Cache name.keys- Keys to map.- Returns:
- Map of nodes to keys.
- Throws:
IgniteCheckedException- If failed.
-
mapKeyToNode
@Nullable public <K> @Nullable ClusterNode mapKeyToNode(String cacheName, K key) throws IgniteCheckedException
Maps single key to a node.- Parameters:
cacheName- Cache name.key- Key to map.- Returns:
- Picked node.
- Throws:
IgniteCheckedException- If failed.
-
mapKeyToNode
@Nullable public <K> @Nullable ClusterNode mapKeyToNode(String cacheName, K key, AffinityTopologyVersion topVer) throws IgniteCheckedException
Maps single key to a node.- Parameters:
cacheName- Cache name.key- Key to map.- Returns:
- Picked node.
- Throws:
IgniteCheckedException- If failed.
-
mapKeyToPrimaryAndBackups
public <K> List<ClusterNode> mapKeyToPrimaryAndBackups(String cacheName, K key, AffinityTopologyVersion topVer) throws IgniteCheckedException
Map single key to primary and backup nodes.- Parameters:
cacheName- Cache name.key- Key to map.topVer- Topology version.- Returns:
- Affinity nodes, primary first.
- Throws:
IgniteCheckedException- If failed.
-
affinityKey
@Nullable public @Nullable Object affinityKey(String cacheName, @Nullable @Nullable Object key) throws IgniteCheckedException
Gets affinity key for cache key.- Parameters:
cacheName- Cache name.key- Cache key.- Returns:
- Affinity key.
- Throws:
IgniteCheckedException- In case of error.
-
affinityProxy
public <K> org.apache.ignite.internal.processors.affinity.GridAffinityProcessor.CacheAffinityProxy<K> affinityProxy(String cacheName)
- Parameters:
cacheName- Cache name.- Returns:
- Cache affinity.
-
affinityCacheFuture
public IgniteInternalFuture<org.apache.ignite.internal.processors.affinity.GridAffinityProcessor.AffinityInfo> affinityCacheFuture(String cacheName, @Nullable @Nullable AffinityTopologyVersion topVer) throws IgniteCheckedException
- Parameters:
cacheName- Cache name.topVer- Topology version.- Returns:
- Affinity cache.
- Throws:
IgniteCheckedException- In case of error.
-
similaryAffinityKey
public Object similaryAffinityKey(AffinityFunction aff, IgnitePredicate<ClusterNode> nodeFilter, int backups, int parts)
- Parameters:
aff- Affinity function.nodeFilter- Node class.backups- Number of backups.parts- Number of partitions.- Returns:
- Key to find caches with similar affinity.
-
printMemoryStats
public void printMemoryStats()
Prints memory statistics (sizes of internal structures, etc.). NOTE: this method is for testing and profiling purposes only.- Specified by:
printMemoryStatsin interfaceGridComponent- Overrides:
printMemoryStatsin classGridProcessorAdapter
-
-