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

## Class TcpDiscoveryNodesRing

- java.lang.Object
- - org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNodesRing

    public class TcpDiscoveryNodesRing
    extends Object

Convenient way to represent topology for `TcpDiscoverySpi`

### Field Summary

Fields
`static IgnitePredicate<TcpDiscoveryNode>` `VISIBLE_NODES` Visible nodes filter.

### Constructor Summary

Constructors
Constructor and Description
`TcpDiscoveryNodesRing()`

### Method Summary

Methods
`boolean` `add(TcpDiscoveryNode node)` Adds node to topology, also initializes node last update time with current system time.
`Collection<TcpDiscoveryNode>` `allNodes()` Gets all nodes in the topology.
`void` `clear()` Removes all remote nodes, leaves only local node.
`Collection<TcpDiscoveryNode>` `clientNodes()`
`TcpDiscoveryNode` `coordinator()` Finds coordinator in the topology.
`TcpDiscoveryNode` `coordinator(Collection<TcpDiscoveryNode> excluded)` Finds coordinator in the topology filtering excluded nodes from the search.
`boolean` `hasRemoteNodes()` Checks whether the topology has remote nodes in.
`boolean` `hasRemoteServerNodes()` Checks whether the topology has remote server nodes in.
`long` `incrementTopologyVersion()` Increments topology version and gets new value.
`void` `localNode(TcpDiscoveryNode locNode)` Sets local node.
`long` `maxInternalOrder()`
`IgniteProductVersion` `minimumNodeVersion()`
`TcpDiscoveryNode` `nextNode()` Finds next node in the topology.
`TcpDiscoveryNode` `nextNode(Collection<TcpDiscoveryNode> excluded)` Finds next node in the topology filtering excluded nodes from search.
`long` `nextNodeOrder()` Increments topology version and gets new value.
`TcpDiscoveryNode` `node(UUID nodeId)` Finds node by ID.
`Collection<TcpDiscoveryNode>` `remoteNodes()` Gets remote nodes.
`TcpDiscoveryNode` `removeNode(UUID nodeId)` Removes node from the topology.
`void` `restoreTopology(Iterable<TcpDiscoveryNode> nodes, long topVer)` Restores topology from parameters values.
`long` `topologyVersion()` Gets current topology version.
`boolean` `topologyVersion(long topVer)` Sets new topology version.
`String` `toString()`
`Collection<TcpDiscoveryNode>` `visibleNodes()` Gets visible nodes in the topology.
`Collection<TcpDiscoveryNode>` `visibleRemoteNodes()` Gets visible remote nodes in the topology.

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### VISIBLE_NODES

    public static final IgnitePredicate<TcpDiscoveryNode> VISIBLE_NODES

Visible nodes filter.

### Constructor Detail

#### TcpDiscoveryNodesRing

    public TcpDiscoveryNodesRing()

### Method Detail

#### minimumNodeVersion

    public IgniteProductVersion minimumNodeVersion()

Returns:
  Minimum node version.

#### localNode

    public void localNode(TcpDiscoveryNode locNode)

Sets local node.

Parameters:
  `locNode` - Local node.

#### allNodes

    public Collection<TcpDiscoveryNode> allNodes()

Gets all nodes in the topology.

Returns:
  Collection of all nodes.

#### visibleNodes

    public Collection<TcpDiscoveryNode> visibleNodes()

Gets visible nodes in the topology.

Returns:
  Collection of visible nodes.

#### remoteNodes

    public Collection<TcpDiscoveryNode> remoteNodes()

Gets remote nodes.

Returns:
  Collection of remote nodes in grid.

#### visibleRemoteNodes

    public Collection<TcpDiscoveryNode> visibleRemoteNodes()

Gets visible remote nodes in the topology.

Returns:
  Collection of visible remote nodes.

#### clientNodes

    public Collection<TcpDiscoveryNode> clientNodes()

Returns:
  Client nodes.

#### hasRemoteNodes

    public boolean hasRemoteNodes()

Checks whether the topology has remote nodes in.

Returns:
  `true` if the topology has remote nodes in.

#### hasRemoteServerNodes

    public boolean hasRemoteServerNodes()

Checks whether the topology has remote server nodes in.

Returns:
  `true` if the topology has remote server nodes in.

#### add

    public boolean add(TcpDiscoveryNode node)

Adds node to topology, also initializes node last update time with current system time.

Parameters:
  `node` - Node to add.
Returns:
  `true` if such node was added and did not present previously in the topology.

#### maxInternalOrder

    public long maxInternalOrder()

Returns:
  Max internal order.

#### restoreTopology

    public void restoreTopology(Iterable<TcpDiscoveryNode> nodes,
                       long topVer)

Restores topology from parameters values.

This method is called when new node receives topology from coordinator. In this case all nodes received are remote for local.

Also initializes nodes last update time with current system time.

Parameters:
  `nodes` - List of remote nodes.
  `topVer` - Topology version.

#### node

    @Nullable
    public TcpDiscoveryNode node(UUID nodeId)

Finds node by ID.

Parameters:
  `nodeId` - Node id to find.
Returns:
  Node with ID provided or `null` if not found.

#### removeNode

    @Nullable
    public TcpDiscoveryNode removeNode(UUID nodeId)

Removes node from the topology.

Parameters:
  `nodeId` - ID of the node to remove.
Returns:
  `true` if node was removed.

#### clear

    public void clear()

Removes all remote nodes, leaves only local node.

This should be called when SPI should be disconnected from topology and reconnected back after.

#### coordinator

    @Nullable
    public TcpDiscoveryNode coordinator()

Finds coordinator in the topology.

Returns:
  Coordinator node that gives versions to topology (node with the smallest order).

#### coordinator

    @Nullable
    public TcpDiscoveryNode coordinator(@Nullable
                                        Collection<TcpDiscoveryNode> excluded)

Finds coordinator in the topology filtering excluded nodes from the search.

This may be used when handling current coordinator leave or failure.

Parameters:
  `excluded` - Nodes to exclude from the search (optional).
Returns:
  Coordinator node among remaining nodes or `null` if all nodes are excluded.

#### nextNode

    @Nullable
    public TcpDiscoveryNode nextNode()

Finds next node in the topology.

Returns:
  Next node.

#### nextNode

    @Nullable
    public TcpDiscoveryNode nextNode(@Nullable
                                     Collection<TcpDiscoveryNode> excluded)

Finds next node in the topology filtering excluded nodes from search.

This may be used when detecting and handling nodes failure.

Parameters:
  `excluded` - Nodes to exclude from the search (optional). If provided, cannot contain local node.
Returns:
  Next node or `null` if all nodes were filtered out or topology contains less than two nodes.

#### topologyVersion

    public long topologyVersion()

Gets current topology version.

Returns:
  Current topology version.

#### topologyVersion

    public boolean topologyVersion(long topVer)

Sets new topology version.

Parameters:
  `topVer` - New topology version (should be greater than current, otherwise no-op).
Returns:
  `True` if topology has been changed.

#### incrementTopologyVersion

    public long incrementTopologyVersion()

Increments topology version and gets new value.

Returns:
  Topology version (incremented).

#### nextNodeOrder

    public long nextNodeOrder()

Increments topology version and gets new value.

Returns:
  Topology version (incremented).

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.7.0
Release Date | : August 1 2016