Class SegmentConsistentHash
- java.lang.Object
-
- org.infinispan.client.hotrod.impl.consistenthash.SegmentConsistentHash
-
- All Implemented Interfaces:
ConsistentHash
public final class SegmentConsistentHash extends Object implements ConsistentHash
- Author:
- Galder ZamarreƱo
-
-
Constructor Summary
Constructors Constructor Description SegmentConsistentHash()
-
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.int
getNumSegments()
int
getSegment(Object key)
SocketAddress[][]
getSegmentOwners()
Map<SocketAddress,Set<Integer>>
getSegmentsByServer()
SocketAddress
getServer(Object key)
void
init(SocketAddress[][] segmentOwners, int numSegments)
void
init(Map<SocketAddress,Set<Integer>> servers2Hash, int numKeyOwners, int hashSpace)
-
-
-
Method Detail
-
init
public void init(Map<SocketAddress,Set<Integer>> servers2Hash, int numKeyOwners, int hashSpace)
- Specified by:
init
in interfaceConsistentHash
-
init
public void init(SocketAddress[][] segmentOwners, int numSegments)
-
getServer
public SocketAddress getServer(Object key)
- Specified by:
getServer
in interfaceConsistentHash
-
getSegment
public int getSegment(Object key)
-
getNormalizedHash
public 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
-
getNumSegments
public int getNumSegments()
-
getSegmentOwners
public SocketAddress[][] getSegmentOwners()
-
-