Package io.hekate.cluster
Class ClusterAddress
- java.lang.Object
-
- io.hekate.cluster.ClusterAddress
-
- All Implemented Interfaces:
Serializable
,Comparable<ClusterAddress>
public class ClusterAddress extends Object implements Comparable<ClusterAddress>, Serializable
Address of theClusterNode
.This address includes both the
node ID
and thesocket address
that can be used to establish network connections with this node.- See Also:
ClusterNode.address()
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ClusterAddress(InetSocketAddress socket, ClusterNodeId id)
Constructs new instance with the specified network address and node identifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ClusterAddress o)
Compares this address with the specified one by comparingid()
s of both addresses.boolean
equals(Object o)
Returnstrue
if the specified object is ofClusterAddress
type and has the sameid()
as this object.int
hashCode()
Returns the hash code ofid()
.String
host()
Returns the host address.ClusterNodeId
id()
Returns the unique identifier of theClusterNode
.int
port()
Returns the port number.InetSocketAddress
socket()
Returns the network address of theClusterNode
.String
toString()
-
-
-
Constructor Detail
-
ClusterAddress
public ClusterAddress(InetSocketAddress socket, ClusterNodeId id)
Constructs new instance with the specified network address and node identifier.- Parameters:
socket
- Network address ofClusterNode
.id
- Unique identifier ofClusterNode
.
-
-
Method Detail
-
id
public ClusterNodeId id()
Returns the unique identifier of theClusterNode
.- Returns:
- Unique identifier of the
ClusterNode
.
-
socket
public InetSocketAddress socket()
Returns the network address of theClusterNode
.- Returns:
- Network address of the
ClusterNode
.
-
host
public String host()
Returns the host address.- Returns:
- Host address.
-
port
public int port()
Returns the port number.- Returns:
- Port number.
-
compareTo
public int compareTo(ClusterAddress o)
Compares this address with the specified one by comparingid()
s of both addresses.- Specified by:
compareTo
in interfaceComparable<ClusterAddress>
-
equals
public boolean equals(Object o)
Returnstrue
if the specified object is ofClusterAddress
type and has the sameid()
as this object.- Overrides:
equals
in classObject
- Parameters:
o
- Object.- Returns:
true
if the specified object is ofClusterAddress
type and has the sameid()
as this object.
-
-