Package io.hekate.partition
Class DefaultPartition
- java.lang.Object
-
- io.hekate.partition.DefaultPartition
-
- All Implemented Interfaces:
Partition
,Comparable<Partition>
public class DefaultPartition extends Object implements Partition
Default implementation ofPartitionMapper
interface.
-
-
Constructor Summary
Constructors Constructor Description DefaultPartition(int id, ClusterNode primary, List<ClusterNode> backup, ClusterTopology topology)
Constructs a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ClusterNode>
backupNodes()
Returns the backup node set of this partition.static DefaultPartition
empty(int id)
Returns a new instance that represents an empty partition.boolean
equals(Object o)
int
hashCode()
int
id()
Returns the partition identifier.List<ClusterNode>
nodes()
ClusterNode
primaryNode()
Returns the primary node that is assigned to this partition.ClusterTopology
topology()
Returns the cluster topology that this partition is mapped to.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.hekate.partition.Partition
compareTo, hasBackupNodes, isPrimary, isPrimary
-
-
-
-
Constructor Detail
-
DefaultPartition
public DefaultPartition(int id, ClusterNode primary, List<ClusterNode> backup, ClusterTopology topology)
Constructs a new instance.- Parameters:
id
- Seeid()
.primary
- SeeprimaryNode()
.backup
- SeebackupNodes()
.topology
- Seetopology()
.
-
-
Method Detail
-
empty
public static DefaultPartition empty(int id)
Returns a new instance that represents an empty partition.- Parameters:
id
- Partition identifier.- Returns:
- Empty partition.
-
id
public int id()
Description copied from interface:Partition
Returns the partition identifier.
-
primaryNode
public ClusterNode primaryNode()
Description copied from interface:Partition
Returns the primary node that is assigned to this partition.- Specified by:
primaryNode
in interfacePartition
- Returns:
- Primary node.
-
backupNodes
public List<ClusterNode> backupNodes()
Description copied from interface:Partition
Returns the backup node set of this partition.- Specified by:
backupNodes
in interfacePartition
- Returns:
- Set of backup nodes or an empty set if there are no backup nodes.
-
nodes
public List<ClusterNode> nodes()
Description copied from interface:Partition
-
topology
public ClusterTopology topology()
Description copied from interface:Partition
Returns the cluster topology that this partition is mapped to.
-
-