## org.jgroups.blocks
Class PartitionedHashMap.ConsistentHashFunction<K>

    java.lang.Object
      org.jgroups.blocks.MembershipListenerAdapter
          org.jgroups.blocks.PartitionedHashMap.ConsistentHashFunction<K>

All Implemented Interfaces:
  PartitionedHashMap.HashFunction<K>, MembershipListener

Enclosing class:
  PartitionedHashMap<K,V>

    public static class PartitionedHashMap.ConsistentHashFunction<K>

extends MembershipListenerAdapter
implements PartitionedHashMap.HashFunction<K>

Field Summary

Fields inherited from class org.jgroups.blocks.MembershipListenerAdapter
`membershipListeners, membershipListenersCache`

Constructor Summary
`PartitionedHashMap.ConsistentHashFunction()`

Method Summary
`Address` `hash(K key, java.util.List<Address> members)` Defines a hash function to pick the right node from the list of cluster nodes.
`void` `viewAccepted(View new_view)` Notify membership listener that new view was accepted.

Methods inherited from class org.jgroups.blocks.MembershipListenerAdapter
`addMembershipListener, block, removeMembershipListener, suspect, unblock`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PartitionedHashMap.ConsistentHashFunction

    public PartitionedHashMap.ConsistentHashFunction()

Method Detail

### hash

    public Address hash(K key,
                        java.util.List<Address> members)

  Description copied from interface: `PartitionedHashMap.HashFunction`
  Defines a hash function to pick the right node from the list of cluster nodes. Ideally, this function uses consistent hashing, so that the same key maps to the same node despite cluster view changes. If a view change causes all keys to hash to different nodes, then PartitionedHashMap will redirect requests to different nodes and this causes unnecessary overhead.

  Specified by:
    `hash` in interface `PartitionedHashMap.HashFunction<K>`
  Parameters:
    `key` - The object to be hashed
    `members` - The membership. This value can be ignored for example if the hash function keeps track of the membership itself, e.g. by registering as a membership listener (`PartitionedHashMap.addMembershipListener(org.jgroups.MembershipListener)` )
  Returns:

### viewAccepted

    public void viewAccepted(View new_view)

  Description copied from class: `MembershipListenerAdapter`
  Notify membership listener that new view was accepted. This method in turn passes new view to all registered membership listeners.

  Specified by:
    `viewAccepted` in interface `MembershipListener`
  Overrides:
    `viewAccepted` in class `MembershipListenerAdapter`

Copyright © 1998-2009 Bela Ban / Red Hat. All Rights Reserved.