Class GridAffinityAssignmentCache


  • public class GridAffinityAssignmentCache
    extends Object
    Affinity cached function.
    • Method Detail

      • similarAffinityKey

        public Object similarAffinityKey()
        Returns:
        Key to find caches with similar affinity.
      • cacheOrGroupName

        public String cacheOrGroupName()
        Returns:
        Group name if it is specified, otherwise cache name.
      • groupId

        public int groupId()
        Returns:
        Cache group ID.
      • initialize

        public void initialize​(AffinityTopologyVersion topVer,
                               List<List<ClusterNode>> affAssignment)
        Initializes affinity with given topology version and assignment.
        Parameters:
        topVer - Topology version.
        affAssignment - Affinity assignment for topology version.
      • idealAssignmentRaw

        @Nullable
        public @Nullable List<List<ClusterNode>> idealAssignmentRaw()
        Returns:
        Assignment.
      • centralizedAffinityFunction

        public boolean centralizedAffinityFunction()
        Returns:
        True if affinity function has AffinityCentralizedFunction annotation.
      • cancelFutures

        public void cancelFutures​(IgniteCheckedException err)
        Kernal stop callback.
        Parameters:
        err - Error.
      • onReconnected

        public void onReconnected()
      • calculate

        public IdealAffinityAssignment calculate​(AffinityTopologyVersion topVer,
                                                 @Nullable
                                                 @Nullable ExchangeDiscoveryEvents events,
                                                 @Nullable
                                                 @Nullable DiscoCache discoCache)
        Calculates ideal assignment for given topology version and events happened since last calculation.
        Parameters:
        topVer - Topology version to calculate affinity cache for.
        events - Discovery events that caused this topology version change.
        discoCache - Discovery cache.
        Returns:
        Ideal affinity assignment.
      • clientEventTopologyChange

        public void clientEventTopologyChange​(DiscoveryEvent evt,
                                              AffinityTopologyVersion topVer)
        Copies previous affinity assignment when discovery event does not cause affinity assignment changes (e.g. client node joins on leaves).
        Parameters:
        evt - Event.
        topVer - Topology version.
      • lastReadyAffinity

        public AffinityAssignment lastReadyAffinity()
        Returns:
        Last initialized affinity assignment.
      • readyFuture

        @Nullable
        public @Nullable IgniteInternalFuture<AffinityTopologyVersion> readyFuture​(AffinityTopologyVersion topVer)
        Gets future that will be completed after topology with version topVer is calculated.
        Parameters:
        topVer - Topology version to await for.
        Returns:
        Future that will be completed after affinity for topology version topVer is calculated.
      • partitions

        public int partitions()
        Returns:
        Partition count.
      • nodes

        public List<ClusterNode> nodes​(int part,
                                       AffinityTopologyVersion topVer)
        Gets affinity nodes for specified partition.
        Parameters:
        part - Partition.
        topVer - Topology version.
        Returns:
        Affinity nodes.
      • partitionPrimariesDifferentToIdeal

        public Set<Integer> partitionPrimariesDifferentToIdeal​(AffinityTopologyVersion topVer)
        Parameters:
        topVer - Topology version.
      • primaryPartitions

        public Set<Integer> primaryPartitions​(UUID nodeId,
                                              AffinityTopologyVersion topVer)
        Get primary partitions for specified node ID.
        Parameters:
        nodeId - Node ID to get primary partitions for.
        topVer - Topology version.
        Returns:
        Primary partitions for specified node ID.
      • backupPartitions

        public Set<Integer> backupPartitions​(UUID nodeId,
                                             AffinityTopologyVersion topVer)
        Get backup partitions for specified node ID.
        Parameters:
        nodeId - Node ID to get backup partitions for.
        topVer - Topology version.
        Returns:
        Backup partitions for specified node ID.
      • dumpDebugInfo

        public boolean dumpDebugInfo()
        Dumps debug information.
        Returns:
        True if there are pending futures.
      • cachedAffinity

        public AffinityAssignment cachedAffinity​(AffinityTopologyVersion topVer)
        Get cached affinity for specified topology version.
        Parameters:
        topVer - Topology version.
        Returns:
        Cached affinity.
        Throws:
        IllegalArgumentException - in case of the specified topology version topVer is earlier than affinity is calculated or the history of assignments is already cleaned.
      • cachedAffinity

        public AffinityAssignment cachedAffinity​(AffinityTopologyVersion topVer,
                                                 AffinityTopologyVersion lastAffChangeTopVer)
        Get cached affinity for specified topology version.
        Parameters:
        topVer - Topology version for which affinity assignment is requested.
        lastAffChangeTopVer - Topology version of last affinity assignment change.
        Returns:
        Cached affinity.
        Throws:
        IllegalArgumentException - in case of the specified topology version topVer is earlier than affinity is calculated or the history of assignments is already cleaned.
      • primaryChanged

        public boolean primaryChanged​(int part,
                                      AffinityTopologyVersion startVer,
                                      AffinityTopologyVersion endVer)
        Parameters:
        part - Partition.
        startVer - Start version.
        endVer - End version.
        Returns:
        True if primary changed or required affinity version not found in history.