org.apache.ignite.internal.managers.discovery

## Class GridDiscoveryManager

- java.lang.Object
- - org.apache.ignite.internal.managers.GridManagerAdapter<DiscoverySpi>
  - - org.apache.ignite.internal.managers.discovery.GridDiscoveryManager

All Implemented Interfaces:
  GridComponent, GridManager

    public class GridDiscoveryManager
    extends GridManagerAdapter<DiscoverySpi>

Discovery SPI manager.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent

`GridComponent.DiscoveryDataExchangeType`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.managers.GridManagerAdapter

`ctx, log`

### Constructor Summary

Constructors
Constructor and Description
`GridDiscoveryManager(GridKernalContext ctx)`

### Method Summary

Methods
`void` `ackTopology(long topVer)` Prints the latest topology info into log taking into account logging/verbosity settings.
`boolean` `addClientNode(String cacheName, UUID clientNodeId, boolean nearEnabled)` Adds near node ID to cache filter.
`void` `addLocalNodeInitializedEventListener(IgniteInClosure<ClusterNode> lsnr)` Adds a listener for local node initialized event.
`boolean` `alive(ClusterNode node)`
`boolean` `alive(UUID nodeId)`
`boolean` `aliveAll(Collection<UUID> nodeIds)`
`Collection<ClusterNode>` `aliveServerNodes()`
`Collection<ClusterNode>` `allNodes()`
`boolean` `cacheAffinityNode(ClusterNode node, String cacheName)` Checks if node is a data node for the given cache.
`Collection<ClusterNode>` `cacheAffinityNodes(int cacheId, AffinityTopologyVersion topVer)` Gets cache nodes for cache with given ID that participate in affinity calculation.
`Collection<ClusterNode>` `cacheAffinityNodes(String cacheName, AffinityTopologyVersion topVer)` Gets cache nodes for cache with given name that participate in affinity calculation.
`boolean` `cacheClientNode(ClusterNode node, String cacheName)`
`boolean` `cacheNearNode(ClusterNode node, String cacheName)`
`boolean` `cacheNode(ClusterNode node, String cacheName)`
`Collection<ClusterNode>` `cacheNodes(AffinityTopologyVersion topVer)` Gets all nodes with at least one cache configured.
`Collection<ClusterNode>` `cacheNodes(int cacheId, AffinityTopologyVersion topVer)` Gets cache nodes for cache with given ID.
`Collection<ClusterNode>` `cacheNodes(String cacheName, AffinityTopologyVersion topVer)` Gets cache nodes for cache with given name.
`Map<String,Map<UUID,Boolean>>` `clientNodesMap()`
`Object` `consistentId()`
`Collection<ClusterNode>` `daemonNodes()`
`DiscoCache` `discoCache()` Gets discovery collection cache from SPI safely guarding against "floating" collections.
`DiscoCache` `discoCache(AffinityTopologyVersion topVer)` Gets discovery collection cache from SPI safely guarding against "floating" collections.
`void` `failNode(UUID nodeId, String warning)`
`ClusterNode` `getAlive(UUID nodeId)`
`long` `gridStartTime()` Gets first grid node start time, see `DiscoverySpi.getGridStartTime()`.
`boolean` `hasNearCache(int cacheId, AffinityTopologyVersion topVer)` Checks if cache with given ID has at least one node with near cache enabled.
`T2<DiscoveryEvent,DiscoCache>` `localJoin()`
`DiscoveryEvent` `localJoinEvent()`
`ClusterNode` `localNode()`
`GridLocalMetrics` `metrics()`
`ClusterNode` `node(AffinityTopologyVersion topVer, UUID id)` Gets node from history for given topology version.
`ClusterNode` `node(UUID nodeId)`
`Map<String,CacheMode>` `nodeCaches(ClusterNode node)`
`Collection<ClusterNode>` `nodes(AffinityTopologyVersion topVer)` Gets all nodes for given topology version.
`Collection<ClusterNode>` `nodes(Collection<UUID> ids, IgnitePredicate<UUID>... p)` Gets collection of node for given node IDs and predicates.
`Collection<ClusterNode>` `nodes(long topVer)` Gets all nodes for given topology version.
`ClusterNode` `oldestAliveCacheServerNode(AffinityTopologyVersion topVer)`
`void` `onBeforeSpiStart()` This method executed before manager will start SPI.
`boolean` `onClientCacheClose(String cacheName, UUID clientNodeId)` Removes near node ID from cache filter.
`protected void` `onKernalStart0()`
`void` `onKernalStop0(boolean cancel)`
`boolean` `pingNode(UUID nodeId)`
`boolean` `pingNodeNoError(UUID nodeId)`
`void` `reconnect()` Leave cluster and try to join again.
`boolean` `reconnectSupported()`
`Collection<ClusterNode>` `remoteCacheNodes(AffinityTopologyVersion topVer)` Gets cache remote nodes for cache with given name.
`Collection<ClusterNode>` `remoteNodes()`
`void` `removeCacheFilter(String cacheName)` Removes dynamic cache filter.
`void` `sendCustomEvent(DiscoveryCustomMessage msg)`
`List<ClusterNode>` `serverNodes(AffinityTopologyVersion topVer)`
`void` `setCacheFilter(String cacheName, IgnitePredicate<ClusterNode> filter, boolean nearEnabled, CacheMode cacheMode)` Adds dynamic cache filter.
`<T extends DiscoveryCustomMessage> void` `setCustomEventListener(Class<T> msgCls, CustomEventListener<T> lsnr)`
`int` `size()`
`void` `start(boolean activeOnStart)` Starts grid component.
`void` `stop(boolean cancel)` Stops grid component.
`Collection<ClusterNode>` `topology(long topVer)` Gets topology by specified version from history storage.
`IgniteInternalFuture<Long>` `topologyFuture(long awaitVer)` Gets future that will be completed when current topology version becomes greater or equal to argument passed.
`long` `topologyHash(Iterable<? extends ClusterNode> nodes)` Gets topology hash for given set of nodes.
`long` `topologyVersion()`
`AffinityTopologyVersion` `topologyVersionEx()`
`boolean` `tryFailNode(UUID nodeId, String warning)`

### Methods inherited from class org.apache.ignite.internal.managers.GridManagerAdapter

`assertParameter, collectGridNodeData, collectJoiningNodeData, discoveryDataType, enabled, getSpi, getSpi, getSpis, inject, onAfterSpiStart, onDisconnected, onGridDataReceived, onJoiningNodeDataReceived, onKernalStart, onKernalStop, onReconnected, printMemoryStats, startInfo, startSpi, stopInfo, stopSpi, toString, validateNode`

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

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

### Constructor Detail

#### GridDiscoveryManager

    public GridDiscoveryManager(GridKernalContext ctx)

Parameters:
  `ctx` - Context.

### Method Detail

#### onBeforeSpiStart

    public void onBeforeSpiStart()

This method executed before manager will start SPI.

Specified by:
  `onBeforeSpiStart` in interface `GridManager`
Overrides:
  `onBeforeSpiStart` in class `GridManagerAdapter<DiscoverySpi>`

#### setCacheFilter

    public void setCacheFilter(String cacheName,
                      IgnitePredicate<ClusterNode> filter,
                      boolean nearEnabled,
                      CacheMode cacheMode)

Adds dynamic cache filter.

Parameters:
  `cacheName` - Cache name.
  `filter` - Cache filter.
  `nearEnabled` - Near enabled flag.
  `cacheMode` - Cache mode.

#### removeCacheFilter

    public void removeCacheFilter(String cacheName)

Removes dynamic cache filter.

Parameters:
  `cacheName` - Cache name.

#### addClientNode

    public boolean addClientNode(String cacheName,
                        UUID clientNodeId,
                        boolean nearEnabled)

Adds near node ID to cache filter.

Parameters:
  `cacheName` - Cache name.
  `clientNodeId` - Near node ID.
  `nearEnabled` - Near enabled flag.
Returns:
  `True` if new node ID was added.

#### onClientCacheClose

    public boolean onClientCacheClose(String cacheName,
                             UUID clientNodeId)

Removes near node ID from cache filter.

Parameters:
  `cacheName` - Cache name.
  `clientNodeId` - Near node ID.
Returns:
  `True` if existing node ID was removed.

#### clientNodesMap

    public Map<String,Map<UUID,Boolean>> clientNodesMap()

Returns:
  Client nodes map.

#### onKernalStart0

    protected void onKernalStart0()
                           throws IgniteCheckedException

Overrides:
  `onKernalStart0` in class `GridManagerAdapter<DiscoverySpi>`
Throws:
  `IgniteCheckedException` - If failed.

#### start

    public void start(boolean activeOnStart)
               throws IgniteCheckedException

Starts grid component.

Throws:
  `IgniteCheckedException` - Throws in case of any errors.

#### setCustomEventListener

    public <T extends DiscoveryCustomMessage> void setCustomEventListener(Class<T> msgCls,
                                                                 CustomEventListener<T> lsnr)

Parameters:
  `msgCls` - Message class.
  `lsnr` - Custom event listener.

#### addLocalNodeInitializedEventListener

    public void addLocalNodeInitializedEventListener(IgniteInClosure<ClusterNode> lsnr)

Adds a listener for local node initialized event.

Parameters:
  `lsnr` - Listener to add.

#### metrics

    public GridLocalMetrics metrics()

Returns:
  Local metrics.

#### ackTopology

    public void ackTopology(long topVer)

Prints the latest topology info into log taking into account logging/verbosity settings.

Parameters:
  `topVer` - Topology version.

#### onKernalStop0

    public void onKernalStop0(boolean cancel)

Overrides:
  `onKernalStop0` in class `GridManagerAdapter<DiscoverySpi>`
Parameters:
  `cancel` - Cancel flag.

#### stop

    public void stop(boolean cancel)
              throws IgniteCheckedException

Stops grid component.

Parameters:
  `cancel` - If `true`, then all ongoing tasks or jobs for relevant components need to be cancelled.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### aliveAll

    public boolean aliveAll(@Nullable
                   Collection<UUID> nodeIds)

Parameters:
  `nodeIds` - Node IDs to check.
Returns:
  `True` if at least one ID belongs to an alive node.

#### alive

    public boolean alive(UUID nodeId)

Parameters:
  `nodeId` - Node ID.
Returns:
  `True` if node for given ID is alive.

#### getAlive

    @Nullable
    public ClusterNode getAlive(UUID nodeId)

Parameters:
  `nodeId` - Node ID.
Returns:
  Node if node is alive.

#### alive

    public boolean alive(ClusterNode node)

Parameters:
  `node` - Node.
Returns:
  `True` if node is alive.

#### pingNode

    public boolean pingNode(UUID nodeId)
                     throws IgniteClientDisconnectedCheckedException

Parameters:
  `nodeId` - ID of the node.
Returns:
  `True` if ping succeeded.
Throws:
  `IgniteClientDisconnectedCheckedException` - If ping failed.

#### pingNodeNoError

    public boolean pingNodeNoError(UUID nodeId)

Parameters:
  `nodeId` - ID of the node.
Returns:
  `True` if ping succeeded.

#### node

    @Nullable
    public ClusterNode node(UUID nodeId)

Parameters:
  `nodeId` - ID of the node.
Returns:
  Node for ID.

#### nodes

    public Collection<ClusterNode> nodes(@Nullable
                                Collection<UUID> ids,
                                IgnitePredicate<UUID>... p)

Gets collection of node for given node IDs and predicates.

Parameters:
  `ids` - Ids to include.
  `p` - Filter for IDs.
Returns:
  Collection with all alive nodes for given IDs.

#### topologyHash

    public long topologyHash(Iterable<? extends ClusterNode> nodes)

Gets topology hash for given set of nodes.

Parameters:
  `nodes` - Subset of grid nodes for hashing.
Returns:
  Hash for given topology.

#### topologyFuture

    public IgniteInternalFuture<Long> topologyFuture(long awaitVer)

Gets future that will be completed when current topology version becomes greater or equal to argument passed.

Parameters:
  `awaitVer` - Topology version to await.
Returns:
  Future.

#### discoCache

    public DiscoCache discoCache()

Gets discovery collection cache from SPI safely guarding against "floating" collections.

Returns:
  Discovery collection cache.

#### discoCache

    public DiscoCache discoCache(AffinityTopologyVersion topVer)

Gets discovery collection cache from SPI safely guarding against "floating" collections.

Returns:
  Discovery collection cache.

#### remoteNodes

    public Collection<ClusterNode> remoteNodes()

Returns:
  All non-daemon remote nodes in topology.

#### allNodes

    public Collection<ClusterNode> allNodes()

Returns:
  All non-daemon nodes in topology.

#### aliveServerNodes

    public Collection<ClusterNode> aliveServerNodes()

Returns:
  all alive server nodes is topology

#### size

    public int size()

Returns:
  Full topology size.

#### nodes

    public Collection<ClusterNode> nodes(long topVer)

Gets all nodes for given topology version.

Parameters:
  `topVer` - Topology version.
Returns:
  Collection of cache nodes.

#### nodes

    public Collection<ClusterNode> nodes(AffinityTopologyVersion topVer)

Gets all nodes for given topology version.

Parameters:
  `topVer` - Topology version.
Returns:
  Collection of cache nodes.

#### serverNodes

    public List<ClusterNode> serverNodes(AffinityTopologyVersion topVer)

Parameters:
  `topVer` - Topology version.
Returns:
  All server nodes for given topology version.

#### node

    public ClusterNode node(AffinityTopologyVersion topVer,
                   UUID id)

Gets node from history for given topology version.

Parameters:
  `topVer` - Topology version.
  `id` - Node ID.
Returns:
  Node.

#### cacheNodes

    public Collection<ClusterNode> cacheNodes(@Nullable
                                     String cacheName,
                                     AffinityTopologyVersion topVer)

Gets cache nodes for cache with given name.

Parameters:
  `cacheName` - Cache name.
  `topVer` - Topology version.
Returns:
  Collection of cache nodes.

#### cacheNodes

    public Collection<ClusterNode> cacheNodes(int cacheId,
                                     AffinityTopologyVersion topVer)

Gets cache nodes for cache with given ID.

Parameters:
  `cacheId` - Cache ID.
  `topVer` - Topology version.
Returns:
  Collection of cache nodes.

#### cacheNodes

    public Collection<ClusterNode> cacheNodes(AffinityTopologyVersion topVer)

Gets all nodes with at least one cache configured.

Parameters:
  `topVer` - Topology version.
Returns:
  Collection of cache nodes.

#### remoteCacheNodes

    public Collection<ClusterNode> remoteCacheNodes(AffinityTopologyVersion topVer)

Gets cache remote nodes for cache with given name.

Parameters:
  `topVer` - Topology version.
Returns:
  Collection of cache nodes.

#### oldestAliveCacheServerNode

    @Nullable
    public ClusterNode oldestAliveCacheServerNode(AffinityTopologyVersion topVer)

Parameters:
  `topVer` - Topology version (maximum allowed node order).
Returns:
  Oldest alive server nodes with at least one cache configured.

#### cacheAffinityNodes

    public Collection<ClusterNode> cacheAffinityNodes(@Nullable
                                             String cacheName,
                                             AffinityTopologyVersion topVer)

Gets cache nodes for cache with given name that participate in affinity calculation.

Parameters:
  `cacheName` - Cache name.
  `topVer` - Topology version.
Returns:
  Collection of cache affinity nodes.

#### cacheAffinityNodes

    public Collection<ClusterNode> cacheAffinityNodes(int cacheId,
                                             AffinityTopologyVersion topVer)

Gets cache nodes for cache with given ID that participate in affinity calculation.

Parameters:
  `cacheId` - Cache ID.
  `topVer` - Topology version.
Returns:
  Collection of cache affinity nodes.

#### cacheAffinityNode

    public boolean cacheAffinityNode(ClusterNode node,
                            String cacheName)

Checks if node is a data node for the given cache.

Parameters:
  `node` - Node to check.
  `cacheName` - Cache name.
Returns:
  `True` if node is a cache data node.

#### cacheNearNode

    public boolean cacheNearNode(ClusterNode node,
                        String cacheName)

Parameters:
  `node` - Node to check.
  `cacheName` - Cache name.
Returns:
  `True` if node has near cache enabled.

#### cacheClientNode

    public boolean cacheClientNode(ClusterNode node,
                          String cacheName)

Parameters:
  `node` - Node to check.
  `cacheName` - Cache name.
Returns:
  `True` if node has client cache (without near cache).

#### cacheNode

    public boolean cacheNode(ClusterNode node,
                    String cacheName)

Parameters:
  `node` - Node to check.
  `cacheName` - Cache name.
Returns:
  If cache with the given name is accessible on the given node.

#### nodeCaches

    public Map<String,CacheMode> nodeCaches(ClusterNode node)

Parameters:
  `node` - Node to check.
Returns:
  Public cache names accessible on the given node.

#### hasNearCache

    public boolean hasNearCache(int cacheId,
                       AffinityTopologyVersion topVer)

Checks if cache with given ID has at least one node with near cache enabled.

Parameters:
  `cacheId` - Cache ID.
  `topVer` - Topology version.
Returns:
  `True` if cache with given name has at least one node with near cache enabled.

#### topology

    @Nullable
    public Collection<ClusterNode> topology(long topVer)

Gets topology by specified version from history storage.

Parameters:
  `topVer` - Topology version.
Returns:
  Topology nodes or `null` if there are no nodes for passed in version.

#### daemonNodes

    public Collection<ClusterNode> daemonNodes()

Returns:
  All daemon nodes in topology.

#### localNode

    public ClusterNode localNode()

Returns:
  Local node.

#### consistentId

    public Object consistentId()

Returns:
  Consistent ID.

#### topologyVersion

    public long topologyVersion()

Returns:
  Topology version.

#### topologyVersionEx

    public AffinityTopologyVersion topologyVersionEx()

Returns:
  Topology version.

#### localJoinEvent

    public DiscoveryEvent localJoinEvent()

Returns:
  Event that represents a local node joined to topology.

#### localJoin

    public T2<DiscoveryEvent,DiscoCache> localJoin()

Returns:
  Tuple that consists of a local join event and discovery cache at the join time.

#### sendCustomEvent

    public void sendCustomEvent(DiscoveryCustomMessage msg)
                         throws IgniteCheckedException

Parameters:
  `msg` - Custom message.
Throws:
  `IgniteCheckedException` - If failed.

#### gridStartTime

    public long gridStartTime()

Gets first grid node start time, see `DiscoverySpi.getGridStartTime()`.

Returns:
  Start time of the first grid node.

#### tryFailNode

    public boolean tryFailNode(UUID nodeId,
                      @Nullable
                      String warning)

Parameters:
  `nodeId` - Node ID.
  `warning` - Warning message to be shown on all nodes.
Returns:
  Whether node is failed.

#### failNode

    public void failNode(UUID nodeId,
                @Nullable
                String warning)

Parameters:
  `nodeId` - Node ID to fail.
  `warning` - Warning message to be shown on all nodes.

#### reconnectSupported

    public boolean reconnectSupported()

Returns:
  `True` if local node client and discovery SPI supports reconnect.

#### reconnect

    public void reconnect()

Leave cluster and try to join again.

Throws:
  `IgniteSpiException` - If failed.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.0.0
Release Date | : April 30 2017