Interface AvailabilityStrategyContext

  • All Known Implementing Classes:
    ClusterCacheStatus

    public interface AvailabilityStrategyContext
    Contains information about the current state of the cache. Also allows AvailabilityStrategy to proceed with a rebalance, a membership update, or an availability mode change.
    Author:
    Mircea Markus, Dan Berindei
    • Method Detail

      • getCacheName

        String getCacheName()
      • getCurrentTopology

        CacheTopology getCurrentTopology()
        Returns:
        The current cache topology.
      • getStableTopology

        CacheTopology getStableTopology()
        Whenever a new cache topology without a pendingCH and with at least numOwners owners for each segment is installed, and the cache is AvailabilityMode.AVAILABLE, the current cache topology is marked as the stable topology. The same happens when a rebalance is scheduled to start, but it doesn't do anything because the current topology is already balanced.
        Returns:
        The last stable cache topology. May be null.
      • getAvailabilityMode

        AvailabilityMode getAvailabilityMode()
        Returns:
        The current availability mode.
      • getExpectedMembers

        List<Address> getExpectedMembers()
        The members of the cache. Includes nodes which have tried to join the cache but are not yet part of the current CacheTopology. Does not include nodes which have left the cluster (either gracefully or abruptly) but are still in the current topology.
      • queueRebalance

        void queueRebalance​(List<Address> newMembers)
        Queue (or start) a rebalance. Use the configured ConsistentHashFactory to create a new balanced consistent hash with the given members. If there is no rebalance in progress, start a rebalance right away. If there is a rebalance in progress, queue another rebalance. If there is a rebalance in the queue as well, it will be replaced with the new one. If newConsistentHash == null, remove any queued rebalance.
      • updateCurrentTopology

        void updateCurrentTopology​(List<Address> newMembers)
        Use the configured ConsistentHashFactory to create a new CH with the given members, but do not start a rebalance. Members missing from the current topology are ignored.
      • updateAvailabilityMode

        void updateAvailabilityMode​(List<Address> actualMembers,
                                    AvailabilityMode mode,
                                    boolean cancelRebalance)
        Enter a new availability mode.
      • updateTopologiesAfterMerge

        void updateTopologiesAfterMerge​(CacheTopology currentTopology,
                                        CacheTopology stableTopology,
                                        AvailabilityMode availabilityMode)
        Updates both the stable and the current topologies. Does not install the current topology on the cache members.
      • calculateConflictHash

        ConsistentHash calculateConflictHash​(ConsistentHash preferredHash,
                                             Set<ConsistentHash> distinctHashes,
                                             List<Address> actualMembers)
        Parameters:
        preferredHash - the base consistent hash
        distinctHashes - a set of all hashes to be utilised as part of the conflict resolution hash
        actualMembers - a set of all valid addresses
        Returns:
        the hash to be utilised as a pending CH during Phase.CONFLICT_RESOLUTION
      • queueConflictResolution

        void queueConflictResolution​(CacheTopology conflictTopology,
                                     Set<Address> preferredNodes)
        Initiates conflict resolution using the conflictTopology, which should have already been broadcast via {@link this#updateTopologiesAfterMerge(CacheTopology, CacheTopology, AvailabilityMode)}
        Parameters:
        conflictTopology - the topology to use during conflict resolution
        preferredNodes - the addresses that belong to the preferred partition as determined by the AvailabilityStrategy
      • restartConflictResolution

        boolean restartConflictResolution​(List<Address> newMembers)
        If CR is in progress, then this method cancels the current CR and starts a new CR phase with an updated topology based upon newMembers and the previously queued CR topology
        Parameters:
        newMembers - the latest members of the current view
        Returns:
        true if conflict resolution was restarted due to the newMembers