P - The type of partition object.public final class ConsistentHashMap<P> extends Object
This implementation maps partitions to one or more points on a circle ranging from Integer.MIN_VALUE to
Integer.MAX_VALUE. The number of points per partition is dictated by the partition's weight. A partition
with a weight which is higher than another partition will receive a proportionally higher load.
| Constructor and Description |
|---|
ConsistentHashMap()
Creates a new consistent hash map which will hash keys using MD5.
|
ConsistentHashMap(org.forgerock.util.Function<Object,Integer,org.forgerock.util.promise.NeverThrowsException> hashFunction)
Creates a new consistent hash map which will hash keys using the provided hash function.
|
| Modifier and Type | Method and Description |
|---|---|
ConsistentHashMap<P> |
put(String partitionId,
P partition)
Puts a partition into this consistent hash map using the default weight which is sufficiently high to ensure a
reasonably uniform distribution among all partitions having the same weight.
|
ConsistentHashMap<P> |
put(String partitionId,
P partition,
int weight)
Puts a partition into this consistent hash map using the specified weight.
|
ConsistentHashMap<P> |
remove(String partitionId)
Removes the partition that was previously added using the provided partition ID.
|
String |
toString() |
public ConsistentHashMap()
public ConsistentHashMap(org.forgerock.util.Function<Object,Integer,org.forgerock.util.promise.NeverThrowsException> hashFunction)
hashFunction - The function which should be used for hashing keys.public ConsistentHashMap<P> put(String partitionId, P partition)
partitionId - The partition ID.partition - The partition.public ConsistentHashMap<P> put(String partitionId, P partition, int weight)
partitionId - The partition ID.partition - The partition.weight - The partition's weight, which should typically be over 200 and never negative.public ConsistentHashMap<P> remove(String partitionId)
partitionId - The partition ID.Copyright © 2017-2020 Wren Security. All Rights Reserved.