Class AbstractConsistentHash

    • Field Detail

      • hashFunction

        protected final org.infinispan.commons.hash.Hash hashFunction
      • members

        protected final List<Address> members
        The membership of the cache topology that uses this CH.
      • capacityFactors

        protected final float[] capacityFactors
      • segmentSize

        protected final int segmentSize
    • Constructor Detail

      • AbstractConsistentHash

        protected AbstractConsistentHash​(org.infinispan.commons.hash.Hash hashFunction,
                                         int numSegments,
                                         List<Address> members,
                                         Map<Address,​Float> capacityFactors)
      • AbstractConsistentHash

        protected AbstractConsistentHash​(org.infinispan.commons.hash.Hash hashFunction,
                                         int numSegments,
                                         List<Address> members,
                                         float[] capacityFactors)
    • Method Detail

      • parseHashFunction

        protected static org.infinispan.commons.hash.Hash parseHashFunction​(ScopedPersistentState state)
      • toScopedState

        public void toScopedState​(ScopedPersistentState state)
        Description copied from interface: ConsistentHash
        Writes this ConsistentHash to the specified scoped state. Before invoking this method, the ConsistentHash addresses will have to be replaced with their corresponding PersistentUUIDs
        Specified by:
        toScopedState in interface ConsistentHash
        Parameters:
        state - the state to which this ConsistentHash will be written
      • getSegment

        public int getSegment​(Object key)
        Specified by:
        getSegment in interface ConsistentHash
        Returns:
        The hash space segment that a key maps to.
      • getNormalizedHash

        public int getNormalizedHash​(Object key)
      • getMembers

        public List<Address> getMembers()
        Description copied from interface: ConsistentHash
        Should return the addresses of the nodes used to create this consistent hash.
        Specified by:
        getMembers in interface ConsistentHash
        Returns:
        set of node addresses.
      • isKeyLocalToNode

        public boolean isKeyLocalToNode​(Address nodeAddress,
                                        Object key)
        Description copied from interface: ConsistentHash
        Test to see whether a key is owned by a given node.
        Specified by:
        isKeyLocalToNode in interface ConsistentHash
        Parameters:
        nodeAddress - address of the node to test
        key - key to test
        Returns:
        true if the key is mapped to the address; false otherwise
      • mergeLists

        protected static void mergeLists​(List<Address> dest,
                                         List<Address> src)
        Adds all elements from src list that do not already exist in dest list to the latter.
        Parameters:
        dest - List where elements are added
        src - List of elements to add - this is never modified
      • getCapacityFactors

        public Map<Address,​Float> getCapacityFactors()
        Description copied from interface: ConsistentHash
        The capacity factor of each member. Determines the relative capacity of each node compared to the others. If null, all the members are assumed to have a capacity factor of 1.
        Specified by:
        getCapacityFactors in interface ConsistentHash