Class SyncConsistentHashFactory

    • Constructor Detail

      • SyncConsistentHashFactory

        public SyncConsistentHashFactory()
    • Method Detail

      • create

        public DefaultConsistentHash create​(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.
        Specified by:
        create in interface ConsistentHashFactory<DefaultConsistentHash>
        Parameters:
        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.
      • updateMembers

        public DefaultConsistentHash updateMembers​(DefaultConsistentHash baseCH,
                                                   List<Address> newMembers,
                                                   Map<Address,​Float> actualCapacityFactors)
        Description copied from interface: ConsistentHashFactory
        Updates an existing consistent hash instance to remove owners that are not in the newMembers list.

        If a segment has at least one owner in newMembers, this method will not add another owner. This guarantees that the new consistent hash can be used immediately, without transferring any state.

        If a segment has no owners in newMembers and the ConsistentHash implementation (e.g. DefaultConsistentHash) requires at least one owner for each segment, this method may add one or more owners for that segment. Since the data in that segment was lost, the new consistent hash can still be used without transferring state.

        Specified by:
        updateMembers in interface ConsistentHashFactory<DefaultConsistentHash>
        Parameters:
        baseCH - An existing consistent hash instance, should not be null
        newMembers - 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:
        A new ConsistentHash instance, or baseCH if the existing instance does not need any changes.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object