Class TcpDiscoveryNode
- java.lang.Object
-
- org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
-
- org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode
-
- All Implemented Interfaces:
Externalizable,Serializable,Comparable<TcpDiscoveryNode>,BaselineNode,ClusterNode,IgniteClusterNode
public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements IgniteClusterNode, Comparable<TcpDiscoveryNode>, Externalizable
Node forTcpDiscoverySpi.This class is not intended for public use and has been made public due to certain limitations of Java technology.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
GridMetadataAwareAdapter.EntryKey
-
-
Constructor Summary
Constructors Constructor Description TcpDiscoveryNode()Public default no-arg constructor forExternalizableinterface.TcpDiscoveryNode(UUID id, Collection<String> addrs, Collection<String> hostNames, int discPort, DiscoveryMetricsProvider metricsProvider, IgniteProductVersion ver, Serializable consistentId)Constructor.TcpDiscoveryNode(ClusterNode node)IMPORTANT!
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<String>addresses()Gets collection of addresses this node is known by.<T> Tattribute(String name)Gets a node attribute.Map<String,Object>attributes()Gets all node attributes.Map<Integer,CacheMetrics>cacheMetrics()Gets collections of cache metrics for this node.voidclientAliveTime(long aliveTime)Set client alive time.booleanclientAliveTimeSet()TcpDiscoveryNodeclientReconnectNode(Map<String,Object> nodeAttrs)UUIDclientRouterNodeId()voidclientRouterNodeId(UUID clientRouterNodeId)intcompareTo(@Nullable TcpDiscoveryNode node)ObjectconsistentId()Gets consistent globally unique node ID.intdiscoveryPort()booleanequals(Object o)Map<String,Object>getAttributes()Gets node attributes without filtering.inthashCode()Collection<String>hostNames()Gets collection of host names this node is known by.UUIDid()Gets globally unique node ID.longinternalOrder()voidinternalOrder(long intOrder)booleanisClient()Whether this node is cache client (seeIgniteConfiguration.isClientMode()).booleanisClientAlive()Test alive check time value.booleanisLocal()Tests whether or not this node is a local node.voidlastExchangeTime(long lastExchangeTimeNanos)Sets the last time a node exchanged a message with a remote node.longlastExchangeTimeNanos()Gets the last time a node exchanged a message with a remote node.@Nullable InetSocketAddresslastSuccessfulAddress()voidlastSuccessfulAddress(InetSocketAddress lastSuccessfulAddr)longlastUpdateTime()Gets node last update time.longlastUpdateTimeNanos()Gets node last update time.voidlastUpdateTimeNanos(long lastUpdateTimeNanos)Sets node last update.voidlocal(boolean loc)ClusterMetricsmetrics()Gets metrics snapshot for this node.voidonClientDisconnected(UUID newId)longorder()Node order within grid topology.voidorder(long order)voidreadExternal(ObjectInput in)voidsetAttributes(Map<String,Object> attrs)Sets node attributes.voidsetCacheMetrics(Map<Integer,CacheMetrics> cacheMetrics)Sets node cache metrics.voidsetConsistentId(Serializable consistentId)Sets consistent globally unique node ID which survives node restarts.voidsetMetrics(ClusterMetrics metrics)Sets node metrics.Collection<InetSocketAddress>socketAddresses()StringtoString()IgniteProductVersionversion()Gets node version.voidversion(IgniteProductVersion ver)booleanvisible()Gets visible flag.voidvisible(boolean visible)Sets visible flag.voidwriteExternal(ObjectOutput out)-
Methods inherited from class org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, removeAllMeta, removeMeta, removeMeta, replaceMeta
-
-
-
-
Constructor Detail
-
TcpDiscoveryNode
public TcpDiscoveryNode()
Public default no-arg constructor forExternalizableinterface.
-
TcpDiscoveryNode
public TcpDiscoveryNode(UUID id, Collection<String> addrs, Collection<String> hostNames, int discPort, DiscoveryMetricsProvider metricsProvider, IgniteProductVersion ver, Serializable consistentId)
Constructor.- Parameters:
id- Node Id.addrs- Addresses.hostNames- Host names.discPort- Port.metricsProvider- Metrics provider.ver- Version.consistentId- Node consistent ID.
-
TcpDiscoveryNode
public TcpDiscoveryNode(ClusterNode node)
IMPORTANT! Only purpose of this constructor is creating node which contains necessary data to store on disc only- Parameters:
node- to copy data from
-
-
Method Detail
-
lastSuccessfulAddress
@Nullable public @Nullable InetSocketAddress lastSuccessfulAddress()
- Returns:
- Last successfully connected address.
-
lastSuccessfulAddress
public void lastSuccessfulAddress(InetSocketAddress lastSuccessfulAddr)
- Parameters:
lastSuccessfulAddr- Last successfully connected address.
-
id
public UUID id()
Gets globally unique node ID. A new ID is generated every time a node restarts.- Specified by:
idin interfaceClusterNode- Returns:
- Globally unique node ID.
-
consistentId
public Object consistentId()
Gets consistent globally unique node ID. UnlikeClusterNode.id()method, this method returns consistent node ID which survives node restarts.- Specified by:
consistentIdin interfaceBaselineNode- Specified by:
consistentIdin interfaceClusterNode- Returns:
- Consistent globally unique node ID.
-
setConsistentId
public void setConsistentId(Serializable consistentId)
Sets consistent globally unique node ID which survives node restarts.- Specified by:
setConsistentIdin interfaceIgniteClusterNode- Parameters:
consistentId- Consistent globally unique node ID.
-
attribute
public <T> T attribute(String name)
Gets a node attribute. Attributes are assigned to nodes at startup viaIgniteConfiguration.getUserAttributes()method.The system adds the following attributes automatically:
{@link System#getProperties()}- All system properties.{@link System#getenv(String)}- All environment properties.- All attributes defined in
IgniteNodeAttributes
Note that attributes cannot be changed at runtime.
- Specified by:
attributein interfaceBaselineNode- Specified by:
attributein interfaceClusterNode- Type Parameters:
T- Attribute Type.- Parameters:
name- Attribute name. Note that attribute names starting withorg.apache.igniteare reserved for internal use.- Returns:
- Attribute value or
null.
-
attributes
public Map<String,Object> attributes()
Gets all node attributes. Attributes are assigned to nodes at startup viaIgniteConfiguration.getUserAttributes()method.The system adds the following attributes automatically:
{@link System#getProperties()}- All system properties.{@link System#getenv(String)}- All environment properties.- All attributes defined in
IgniteNodeAttributes
Note that attributes cannot be changed at runtime.
- Specified by:
attributesin interfaceBaselineNode- Specified by:
attributesin interfaceClusterNode- Returns:
- All node attributes.
-
setAttributes
public void setAttributes(Map<String,Object> attrs)
Sets node attributes.- Parameters:
attrs- Node attributes.
-
getAttributes
public Map<String,Object> getAttributes()
Gets node attributes without filtering.- Returns:
- Node attributes without filtering.
-
metrics
public ClusterMetrics metrics()
Gets metrics snapshot for this node. Note that node metrics are constantly updated and provide up to date information about nodes. For example, you can get an idea about CPU load on remote node viaClusterMetrics.getCurrentCpuLoad()method and use it duringComputeTask.map(List, Object)or during collision resolution.Node metrics are updated with some delay which is controlled by
IgniteConfiguration.getMetricsUpdateFrequency()parameter. By default the update will happen every2seconds.- Specified by:
metricsin interfaceClusterNode- Returns:
- Runtime metrics snapshot for this node.
-
setMetrics
public void setMetrics(ClusterMetrics metrics)
Sets node metrics.- Specified by:
setMetricsin interfaceIgniteClusterNode- Parameters:
metrics- Node metrics.
-
cacheMetrics
public Map<Integer,CacheMetrics> cacheMetrics()
Gets collections of cache metrics for this node. Note that node cache metrics are constantly updated and provide up to date information about caches.Cache metrics are updated with some delay which is directly related to metrics update frequency. For example, by default the update will happen every
2seconds.- Specified by:
cacheMetricsin interfaceIgniteClusterNode- Returns:
- Runtime metrics snapshots for this node.
-
setCacheMetrics
public void setCacheMetrics(Map<Integer,CacheMetrics> cacheMetrics)
Sets node cache metrics.- Specified by:
setCacheMetricsin interfaceIgniteClusterNode- Parameters:
cacheMetrics- Cache metrics.
-
internalOrder
public long internalOrder()
- Returns:
- Internal order.
-
internalOrder
public void internalOrder(long intOrder)
- Parameters:
intOrder- Internal order of the node.
-
order
public long order()
Description copied from interface:ClusterNodeNode order within grid topology. Discovery SPIs that support node ordering will assign a proper order to each node and will guarantee that discovery event notifications for new nodes will come in proper order. All other SPIs not supporting ordering may choose to return node startup time here.NOTE: in cases when discovery SPI doesn't support ordering Ignite cannot guarantee that orders on all nodes will be unique or chronologically correct. If such guarantee is required - make sure use discovery SPI that provides ordering.
- Specified by:
orderin interfaceClusterNode- Returns:
- Order.
-
order
public void order(long order)
- Parameters:
order- Order of the node.
-
version
public IgniteProductVersion version()
Gets node version.- Specified by:
versionin interfaceClusterNode- Returns:
- Node version.
-
version
public void version(IgniteProductVersion ver)
- Parameters:
ver- Version.
-
addresses
public Collection<String> addresses()
Gets collection of addresses this node is known by.If
IgniteConfiguration.getLocalHost()value isn'tnullnode will try to use that address for all communications and returned collection will contain only that address. If it isnullthen local wildcard address will be used, and Ignite will make the best effort to supply all addresses of that node in returned collection.- Specified by:
addressesin interfaceClusterNode- Returns:
- Collection of addresses.
-
isLocal
public boolean isLocal()
Tests whether or not this node is a local node.- Specified by:
isLocalin interfaceClusterNode- Returns:
Trueif this node is a local node,falseotherwise.
-
local
public void local(boolean loc)
- Parameters:
loc- Grid local node flag.
-
hostNames
public Collection<String> hostNames()
Gets collection of host names this node is known by.If
IgniteConfiguration.getLocalHost()value isn'tnullnode will try to use the host name of that resolved address for all communications and returned collection will contain only that host name. If that host name can not be resolved then ip address returned by methodClusterNode.addresses()is used.If
IgniteConfiguration.getLocalHost()value isnullthen local wildcard address will be used, and this method returns host names of all addresses of that node.Note: the loopback address will be omitted in results.
- Specified by:
hostNamesin interfaceClusterNode- Returns:
- Collection of host names.
-
discoveryPort
public int discoveryPort()
- Returns:
- Discovery port.
-
socketAddresses
public Collection<InetSocketAddress> socketAddresses()
- Returns:
- Addresses that could be used by discovery.
-
lastUpdateTime
public long lastUpdateTime()
Gets node last update time. Used for logging purposes only.
Note that this method tries to convertnanoTimeinternal JVM time format into a regular timestamp. This might lead to errors if there was GC between measuring of current timestamp and current nano time, but generally it might be ignored.- Returns:
- Time of the last metrics update.
- See Also:
System.currentTimeMillis(),System.nanoTime()
-
lastUpdateTimeNanos
public long lastUpdateTimeNanos()
Gets node last update time.- Returns:
- Time of the last metrics update as returned by
System.nanoTime().
-
lastUpdateTimeNanos
public void lastUpdateTimeNanos(long lastUpdateTimeNanos)
Sets node last update.- Parameters:
lastUpdateTimeNanos- Time of last metrics update.
-
lastExchangeTimeNanos
public long lastExchangeTimeNanos()
Gets the last time a node exchanged a message with a remote node.- Returns:
- Time in nanoseconds as returned by
System.nanoTime().
-
lastExchangeTime
public void lastExchangeTime(long lastExchangeTimeNanos)
Sets the last time a node exchanged a message with a remote node.- Parameters:
lastExchangeTimeNanos- Time in nanoseconds.
-
visible
public boolean visible()
Gets visible flag.- Returns:
trueif node is in visible state.
-
visible
public void visible(boolean visible)
Sets visible flag.- Parameters:
visible-trueif node is in visible state.
-
isClient
public boolean isClient()
Whether this node is cache client (seeIgniteConfiguration.isClientMode()).- Specified by:
isClientin interfaceClusterNode- Returns:
True if client.- See Also:
IgniteConfiguration.isClientMode()
-
isClientAlive
public boolean isClientAlive()
Test alive check time value.- Returns:
Trueif client alive,Falseotherwise.
-
clientAliveTime
public void clientAliveTime(long aliveTime)
Set client alive time.- Parameters:
aliveTime- Alive time interval.
-
clientAliveTimeSet
public boolean clientAliveTimeSet()
- Returns:
trueif client alive check time initialized.
-
clientRouterNodeId
public UUID clientRouterNodeId()
- Returns:
- Client router node ID.
-
clientRouterNodeId
public void clientRouterNodeId(UUID clientRouterNodeId)
- Parameters:
clientRouterNodeId- Client router node ID.
-
onClientDisconnected
public void onClientDisconnected(UUID newId)
- Parameters:
newId- New node ID.
-
clientReconnectNode
public TcpDiscoveryNode clientReconnectNode(Map<String,Object> nodeAttrs)
- Parameters:
nodeAttrs- Current node attributes.- Returns:
- Copy of local node for client reconnect request.
-
compareTo
public int compareTo(@Nullable @Nullable TcpDiscoveryNode node)- Specified by:
compareToin interfaceComparable<TcpDiscoveryNode>
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
-