Package org.onosproject.mastership
Class MastershipInfo
- java.lang.Object
-
- org.onosproject.mastership.MastershipInfo
-
public final class MastershipInfo extends java.lang.Object
Mastership info.
-
-
Constructor Summary
Constructors Constructor Description MastershipInfo()
MastershipInfo(long term, java.util.Optional<NodeId> master, com.google.common.collect.ImmutableMap<NodeId,MastershipRole> roles)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<NodeId>
backups()
Returns a sorted list of standby nodes.boolean
equals(java.lang.Object object)
MastershipRole
getRole(NodeId nodeId)
Returns the current role for the given node.java.util.List<NodeId>
getRoles(MastershipRole role)
Returns the list of nodes with the given role.int
hashCode()
java.util.Optional<NodeId>
master()
Returns the current master.long
term()
Returns the mastership term.java.lang.String
toString()
-
-
-
Constructor Detail
-
MastershipInfo
public MastershipInfo()
-
MastershipInfo
public MastershipInfo(long term, java.util.Optional<NodeId> master, com.google.common.collect.ImmutableMap<NodeId,MastershipRole> roles)
-
-
Method Detail
-
term
public long term()
Returns the mastership term.- Returns:
- the mastership term
-
master
public java.util.Optional<NodeId> master()
Returns the current master.- Returns:
- the current master
-
backups
public java.util.List<NodeId> backups()
Returns a sorted list of standby nodes.- Returns:
- a sorted list of standby nodes
-
getRoles
public java.util.List<NodeId> getRoles(MastershipRole role)
Returns the list of nodes with the given role.- Parameters:
role
- the role by which to filter nodes- Returns:
- an immutable list of nodes with the given role sorted in priority order
-
getRole
public MastershipRole getRole(NodeId nodeId)
Returns the current role for the given node.- Parameters:
nodeId
- the node for which to return the current role- Returns:
- the current role for the given node
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-