Class ConsistentHashV2
- java.lang.Object
-
- org.infinispan.client.hotrod.impl.consistenthash.ConsistentHashV2
-
- All Implemented Interfaces:
ConsistentHash
public class ConsistentHashV2 extends Object implements ConsistentHash
Version 2 of the ConsistentHash function. Uses MurmurHash3.- Since:
- 5.0
- Author:
- manik
- See Also:
MurmurHash3
-
-
Field Summary
Fields Modifier and Type Field Description protected org.infinispan.commons.hash.Hash
hash
-
Constructor Summary
Constructors Constructor Description ConsistentHashV2()
ConsistentHashV2(Random rnd)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getNormalizedHash(Object object)
Computes hash code of a given object, and then normalizes it to ensure a positive value is always returned.Map<SocketAddress,Set<Integer>>
getSegmentsByServer()
SocketAddress
getServer(Object key)
void
init(Map<SocketAddress,Set<Integer>> servers2Hash, int numKeyOwners, int hashSpace)
void
setHash(org.infinispan.commons.hash.Hash hash)
-
-
-
Constructor Detail
-
ConsistentHashV2
public ConsistentHashV2(Random rnd)
-
ConsistentHashV2
public ConsistentHashV2()
-
-
Method Detail
-
init
public void init(Map<SocketAddress,Set<Integer>> servers2Hash, int numKeyOwners, int hashSpace)
- Specified by:
init
in interfaceConsistentHash
-
getServer
public SocketAddress getServer(Object key)
- Specified by:
getServer
in interfaceConsistentHash
-
setHash
public void setHash(org.infinispan.commons.hash.Hash hash)
-
getNormalizedHash
public final int getNormalizedHash(Object object)
Description copied from interface:ConsistentHash
Computes hash code of a given object, and then normalizes it to ensure a positive value is always returned.- Specified by:
getNormalizedHash
in interfaceConsistentHash
- Parameters:
object
- to hash- Returns:
- a non-null, non-negative normalized hash code for a given object
-
getSegmentsByServer
public Map<SocketAddress,Set<Integer>> getSegmentsByServer()
- Specified by:
getSegmentsByServer
in interfaceConsistentHash
-
-