org.apache.ignite.spi.discovery.tcp.internal

## 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>, ClusterNode

    public class TcpDiscoveryNode
    extends GridMetadataAwareAdapter
    implements ClusterNode, Comparable<TcpDiscoveryNode>, Externalizable

Node for `TcpDiscoverySpi`.

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 and Description
`TcpDiscoveryNode()` Public default no-arg constructor for `Externalizable` interface.
`TcpDiscoveryNode(UUID id, Collection<String> addrs, Collection<String> hostNames, int discPort, DiscoveryMetricsProvider metricsProvider, IgniteProductVersion ver, Serializable consistentId)` Constructor.

### Method Summary

Methods
`Collection<String>` `addresses()` Gets collection of addresses this node is known by.
`void` `aliveCheck(int aliveCheck)`
`<T> T` `attribute(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.
`TcpDiscoveryNode` `clientReconnectNode()`
`UUID` `clientRouterNodeId()`
`void` `clientRouterNodeId(UUID clientRouterNodeId)`
`int` `compareTo(TcpDiscoveryNode node)`
`Object` `consistentId()` Gets consistent globally unique node ID.
`int` `decrementAliveCheck()` Decrements alive check value and returns new one.
`int` `discoveryPort()`
`boolean` `equals(Object o)`
`Map<String,Object>` `getAttributes()` Gets node attributes without filtering.
`int` `hashCode()`
`Collection<String>` `hostNames()` Gets collection of host names this node is known by.
`UUID` `id()` Gets globally unique node ID.
`long` `internalOrder()`
`void` `internalOrder(long intOrder)`
`boolean` `isClient()` Tests whether or not this node is connected to cluster as a client.
`boolean` `isDaemon()` Tests whether or not this node is a daemon.
`boolean` `isLocal()` Tests whether or not this node is a local node.
`long` `lastExchangeTime()` Gets the last time a node exchanged a message with a remote node.
`void` `lastExchangeTime(long lastExchangeTime)` Sets the last time a node exchanged a message with a remote node.
`InetSocketAddress` `lastSuccessfulAddress()`
`void` `lastSuccessfulAddress(InetSocketAddress lastSuccessfulAddr)`
`long` `lastUpdateTime()` Gets node last update time.
`void` `lastUpdateTime(long lastUpdateTime)` Sets node last update.
`void` `local(boolean loc)`
`ClusterMetrics` `metrics()` Gets metrics snapshot for this node.
`void` `onClientDisconnected(UUID newId)`
`long` `order()` Node order within grid topology.
`void` `order(long order)`
`void` `readExternal(ObjectInput in)`
`void` `setAttributes(Map<String,Object> attrs)` Sets node attributes.
`void` `setCacheMetrics(Map<Integer,CacheMetrics> cacheMetrics)` Sets node cache metrics.
`void` `setMetrics(ClusterMetrics metrics)` Sets node metrics.
`Collection<InetSocketAddress>` `socketAddresses()`
`String` `toString()`
`IgniteProductVersion` `version()` Gets node version.
`void` `version(IgniteProductVersion ver)`
`boolean` `visible()` Gets visible flag.
`void` `visible(boolean visible)` Sets visible flag.
`void` `writeExternal(ObjectOutput out)`

### Methods inherited from class org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter

`addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, readExternalMeta, removeAllMeta, removeMeta, removeMeta, replaceMeta, writeExternalMeta`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### TcpDiscoveryNode

    public TcpDiscoveryNode()

Public default no-arg constructor for `Externalizable` interface.

#### 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.

### Method Detail

#### lastSuccessfulAddress

    @Nullable
    public 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:
  `id` in interface `ClusterNode`
Returns:
  Globally unique node ID.

#### consistentId

    public Object consistentId()

Gets consistent globally unique node ID. Unlike `ClusterNode.id()` method, this method returns consistent node ID which survives node restarts.

Specified by:
  `consistentId` in interface `ClusterNode`
Returns:
  Consistent globally unique node ID.

#### attribute

    public <T> T attribute(String name)

Gets a node attribute. Attributes are assigned to nodes at startup via `IgniteConfiguration.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:
  `attribute` in interface `ClusterNode`
Type Parameters:
  `T` - Attribute Type.
Parameters:
  `name` - Attribute name. Note that attribute names starting with `org.apache.ignite` are 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 via `IgniteConfiguration.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:
  `attributes` in interface `ClusterNode`
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 via `ClusterMetrics.getCurrentCpuLoad()` method and use it during `ComputeTask.map(List, Object)` or during collision resolution.

Node metrics are updated with some delay which is directly related to heartbeat frequency. For example, when used with default `TcpDiscoverySpi` the update will happen every `2` seconds.

Specified by:
  `metrics` in interface `ClusterNode`
Returns:
  Runtime metrics snapshot for this node.

#### setMetrics

    public void setMetrics(ClusterMetrics metrics)

Sets node metrics.

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 heartbeat frequency. For example, when used with default `TcpDiscoverySpi` the update will happen every `2` seconds.

Returns:
  Runtime metrics snapshots for this node.

#### setCacheMetrics

    public void setCacheMetrics(Map<Integer,CacheMetrics> cacheMetrics)

Sets node cache metrics.

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: `ClusterNode`
Node 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:
  `order` in interface `ClusterNode`
Returns:
  Order.

#### order

    public void order(long order)

Parameters:
  `order` - Order of the node.

#### version

    public IgniteProductVersion version()

Gets node version.

Specified by:
  `version` in interface `ClusterNode`
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't `null` node will try to use that address for all communications and returned collection will contain only that address. If it is `null` then 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:
  `addresses` in interface `ClusterNode`
Returns:
  Collection of addresses.

#### isLocal

    public boolean isLocal()

Tests whether or not this node is a local node.

Specified by:
  `isLocal` in interface `ClusterNode`
Returns:
  `True` if this node is a local node, `false` otherwise.

#### local

    public void local(boolean loc)

Parameters:
  `loc` - Grid local node flag.

#### isDaemon

    public boolean isDaemon()

Tests whether or not this node is a daemon.

Daemon nodes are the usual cluster nodes that participate in topology but are not visible on the main APIs, i.e. they are not part of any cluster group. The only way to see daemon nodes is to use `ClusterGroup.forDaemons()` method.

Daemon nodes are used primarily for management and monitoring functionality that is build on Ignite and needs to participate in the topology, but should be excluded from the "normal" topology, so that they won't participate in the task execution or data grid operations.

Application code should never use daemon nodes.

Specified by:
  `isDaemon` in interface `ClusterNode`
Returns:
  `True` if this node is a daemon, `false` otherwise.

#### hostNames

    public Collection<String> hostNames()

Gets collection of host names this node is known by.

If `IgniteConfiguration.getLocalHost()` value isn't `null` node 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 method `ClusterNode.addresses()` is used.

If `IgniteConfiguration.getLocalHost()` value is `null` then 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:
  `hostNames` in interface `ClusterNode`
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.

Returns:
  Time of the last heartbeat.

#### lastUpdateTime

    public void lastUpdateTime(long lastUpdateTime)

Sets node last update.

Parameters:
  `lastUpdateTime` - Time of last metrics update.

#### lastExchangeTime

    public long lastExchangeTime()

Gets the last time a node exchanged a message with a remote node.

Returns:
  Time in milliseconds.

#### lastExchangeTime

    public void lastExchangeTime(long lastExchangeTime)

Sets the last time a node exchanged a message with a remote node.

Parameters:
  `lastExchangeTime` - Time in milliseconds.

#### visible

    public boolean visible()

Gets visible flag.

Returns:
  `true` if node is in visible state.

#### visible

    public void visible(boolean visible)

Sets visible flag.

Parameters:
  `visible` - `true` if node is in visible state.

#### isClient

    public boolean isClient()

Tests whether or not this node is connected to cluster as a client.

Do not confuse client in terms of discovery `DiscoverySpi.isClientMode()` and client in terms of cache `IgniteConfiguration.isClientMode()`. Cache clients cannot carry data, while topology clients connect to topology in a different way.

Specified by:
  `isClient` in interface `ClusterNode`
Returns:
  `True` if this node is a client node, `false` otherwise.
See Also:
  `IgniteConfiguration.isClientMode()`, `Ignition.isClientMode()`, `DiscoverySpi.isClientMode()`

#### decrementAliveCheck

    public int decrementAliveCheck()

Decrements alive check value and returns new one.

Returns:
  Alive check value.

#### aliveCheck

    public void aliveCheck(int aliveCheck)

Parameters:
  `aliveCheck` - Alive check value.

#### 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()

Returns:
  Copy of local node for client reconnect request.

#### compareTo

    public int compareTo(@Nullable
                TcpDiscoveryNode node)

Specified by:
  `compareTo` in interface `Comparable<TcpDiscoveryNode>`

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0.final
Release Date | : December 29 2015