Package io.hekate.partition
Class PartitionMapperBase
- java.lang.Object
-
- io.hekate.partition.PartitionMapperBase
-
- All Implemented Interfaces:
PartitionMapper
- Direct Known Subclasses:
RendezvousHashMapper
,UpdatablePartitionMapper
public abstract class PartitionMapperBase extends Object implements PartitionMapper
Abstract base class forPartitionMapper
implementations.
-
-
Constructor Summary
Constructors Constructor Description PartitionMapperBase(int partitions, int backupNodes)
Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
backupNodes()
Returns the amount of backup nodes that should be assigned to each partition.Partition
map(Object key)
Maps the specified key to aPartition
.Partition
mapInt(int key)
int
partitions()
Returns the total amount of partitions.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.hekate.partition.PartitionMapper
copy, isSnapshot, partition, snapshot, topology
-
-
-
-
Constructor Detail
-
PartitionMapperBase
public PartitionMapperBase(int partitions, int backupNodes)
Constructs a new instance.- Parameters:
partitions
- Seepartitions()
.backupNodes
- SeebackupNodes()
.
-
-
Method Detail
-
map
public Partition map(Object key)
Description copied from interface:PartitionMapper
Maps the specified key to aPartition
.Note that the returned
Partition
instances are immutable and will not reflect changes in the cluster topology. Consider calling this method with the same key in order to obtain thePartition
instance with the latest cluster topology mapping.- Specified by:
map
in interfacePartitionMapper
- Parameters:
key
- Data key.- Returns:
- Partition.
- See Also:
Partition.primaryNode()
,Partition.backupNodes()
-
mapInt
public Partition mapInt(int key)
Description copied from interface:PartitionMapper
Maps the specified key ofInteger
type to aPartition
.Note that the returned
Partition
instances are immutable and will not reflect changes in the cluster topology. Consider calling this method with the same key in order to obtain thePartition
instance with the latest cluster topology mapping.- Specified by:
mapInt
in interfacePartitionMapper
- Parameters:
key
- Data key.- Returns:
- Partition.
- See Also:
Partition.primaryNode()
,Partition.backupNodes()
-
partitions
public int partitions()
Description copied from interface:PartitionMapper
Returns the total amount of partitions.- Specified by:
partitions
in interfacePartitionMapper
- Returns:
- Total amount of partitions
-
backupNodes
public int backupNodes()
Description copied from interface:PartitionMapper
Returns the amount of backup nodes that should be assigned to each partition.- Specified by:
backupNodes
in interfacePartitionMapper
- Returns:
- Amount of backup nodes that should be assigned to each partition.
-
-