Class ScatteredConsistentHashFactory

    • Constructor Detail

      • ScatteredConsistentHashFactory

        public ScatteredConsistentHashFactory()
    • Method Detail

      • create

        public ScatteredConsistentHash create​(org.infinispan.commons.hash.Hash hashFunction,
                                              int numOwners,
                                              int numSegments,
                                              List<Address> members,
                                              Map<Address,​Float> capacityFactors)
        Description copied from interface: ConsistentHashFactory
        Create a new consistent hash instance. The consistent hash will be balanced.
        Parameters:
        hashFunction - The hash function to use on top of the keys' own hashCode() implementation.
        numOwners - The ideal number of owners for each key. The created consistent hash can have more or less owners, but each key will have at least one owner.
        numSegments - Number of hash-space segments. The implementation may round up the number of segments for performance, or may ignore the parameter altogether.
        members - A list of addresses representing the new cache members.
        capacityFactors - The capacity factor of each member. Determines the relative capacity of each node compared to the others. The implementation may ignore this parameter. If null, all the members are assumed to have a capacity factor of 1.
      • fromPersistentState

        public ScatteredConsistentHash fromPersistentState​(ScopedPersistentState state)
        Description copied from interface: ConsistentHashFactory
        Recreates a ConsistentHash from a previously stored persistent state. The returned ConsistentHash will not have proper addresses, but PersistentUUIDs instead so they will need to be replaced
        Parameters:
        state - the state to restore
      • updateMembers

        public ScatteredConsistentHash updateMembers​(ScatteredConsistentHash baseCH,
                                                     List<Address> actualMembers,
                                                     Map<Address,​Float> actualCapacityFactors)
        Leavers are removed and segments without owners are assigned new owners. Joiners might get some of the un-owned segments but otherwise they are not taken into account (that should happen during a rebalance).
        Parameters:
        baseCH - An existing consistent hash instance, should not be null
        actualMembers - A list of addresses representing the new cache members.
        actualCapacityFactors - The capacity factor of each member. Determines the relative capacity of each node compared to the others. The implementation may ignore this parameter. If null, all the members are assumed to have a capacity factor of 1.
        Returns:
      • rebalance

        public ScatteredConsistentHash rebalance​(ScatteredConsistentHash baseCH)
        Description copied from interface: ConsistentHashFactory
        Create a new consistent hash instance, based on an existing instance, but balanced according to the implementation's rules.
        Parameters:
        baseCH - An existing consistent hash instance, should not be null
        Returns:
        A new ConsistentHash instance, or baseCH if the existing instance does not need any changes.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object