Package io.hekate.cluster
Interface ClusterNode
-
- All Superinterfaces:
ClusterNodeIdSupport
,Comparable<ClusterNode>
public interface ClusterNode extends Comparable<ClusterNode>, ClusterNodeIdSupport
Provides information about a single cluster node.- See Also:
ClusterTopology
,ClusterService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ClusterAddress
address()
Returns the network address of this node.int
compareTo(ClusterNode o)
Compares this node with the specified one based onid()
value.boolean
hasProperty(String name)
Returnstrue
if this node has a property with the specified name (seeproperties()
).boolean
hasRole(String role)
Returnstrue
if this node has the specified role (seeroles()
).boolean
hasService(Class<? extends Service> type)
Returnstrue
if this node has a service of the specified type.ClusterNodeId
id()
Returns the universally unique identifier of this node.boolean
isLocal()
Returnstrue
if this is a local node.boolean
isRemote()
Returnstrue
if this is a remote node.int
joinOrder()
Returns the cluster join order.String
name()
Returns the name of this node.Map<String,String>
properties()
Returns the immutable map of properties that are configured for this node.String
property(String name)
Returns value for the specified property name (seeproperties()
).Set<String>
roles()
Returns the immutable set of roles that are configured for this node.ClusterNodeRuntime
runtime()
Returns information about the JVM of this node.ServiceInfo
service(Class<? extends Service> type)
Returns the service information for the specified type.Map<String,ServiceInfo>
services()
Returns the immutable map of services that are provided by this node, with theservice type
as the key.InetSocketAddress
socket()
Returns the network socket address of this node.
-
-
-
Method Detail
-
id
ClusterNodeId id()
Returns the universally unique identifier of this node.- Specified by:
id
in interfaceClusterNodeIdSupport
- Returns:
- Universally unique identifier of this node.
-
name
String name()
Returns the name of this node. Returns an empty string if this node doesn't have a configured name.Value of this property can be configured via
HekateBootstrap.setNodeName(String)
method.- Returns:
- Name of this node or an empty string if node name is not configured.
-
isLocal
boolean isLocal()
Returnstrue
if this is a local node.- Returns:
true
if this is a local node.- See Also:
isRemote()
-
isRemote
boolean isRemote()
Returnstrue
if this is a remote node.- Returns:
true
if this is a remote node.- See Also:
isLocal()
-
address
ClusterAddress address()
Returns the network address of this node.Network address can be configured by the following methods:
- Returns:
- Network address of this node.
-
socket
InetSocketAddress socket()
Returns the network socket address of this node.This is a shortcut for
address()
.getSocket()
- Returns:
- Network socket address of this node.
-
runtime
ClusterNodeRuntime runtime()
Returns information about the JVM of this node.- Returns:
- Information about the JVM of this node.
-
roles
Set<String> roles()
Returns the immutable set of roles that are configured for this node. Returns an empty set if roles are not configured for this node.Roles can be configured via
HekateBootstrap.setRoles(List)
method.- Returns:
- Immutable set of node roles aor an empty set if roles are not configured.
-
hasRole
boolean hasRole(String role)
Returnstrue
if this node has the specified role (seeroles()
).- Parameters:
role
- Role.- Returns:
true
if this node has the specified role.
-
properties
Map<String,String> properties()
Returns the immutable map of properties that are configured for this node. Returns an empty map if properties are not configured for this node.Properties can be configured via
HekateBootstrap.setProperties(Map)
method.- Returns:
- Immutable map of node properties or an empty map if properties are not configured.
-
property
String property(String name)
Returns value for the specified property name (seeproperties()
).- Parameters:
name
- Property name.- Returns:
- Property value or
null
if there is no such property.
-
hasProperty
boolean hasProperty(String name)
Returnstrue
if this node has a property with the specified name (seeproperties()
).- Parameters:
name
- Property name.- Returns:
true
if this node has a property with the specified name.
-
hasService
boolean hasService(Class<? extends Service> type)
Returnstrue
if this node has a service of the specified type.- Parameters:
type
- Service type (must be an interface that extendsService
).- Returns:
true
if this node has a service of the specified type.- See Also:
services()
-
service
ServiceInfo service(Class<? extends Service> type)
Returns the service information for the specified type.- Parameters:
type
- Service type (must be an interface that extendsService
).- Returns:
- Service instance or
null
if there is no such service. - See Also:
services()
-
services
Map<String,ServiceInfo> services()
Returns the immutable map of services that are provided by this node, with theservice type
as the key.- Returns:
- Immutable map of services.
- See Also:
HekateBootstrap.setServices(List)
-
joinOrder
int joinOrder()
Returns the cluster join order. Indexing the join order begins with 1, so the first node that joins the cluster has a value of 1, the second node has a value of 2, and so on. The value of this property is initialized only when the node joins the cluster and is NOT updated if the previous (old) node leaves the cluster.Note that the default value for this property is 0 and it is initialized with its actual value only when the node switches to the
Hekate.State.UP
state.- Returns:
- Cluster join order or 0 if node is not joined yet.
-
compareTo
int compareTo(ClusterNode o)
Compares this node with the specified one based onid()
value.- Specified by:
compareTo
in interfaceComparable<ClusterNode>
- Parameters:
o
- Other node.- Returns:
- Result of
id()
values comparison.
-
-