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
`static String` `NODES_SYS_VIEW`
`static String` `NODES_SYS_VIEW_DESC`

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

`ctx, log`

### Constructor Summary

Constructors
Constructor and Description
`GridDiscoveryManager(GridKernalContext ctx)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`void` `ackTopology(long topVer, int evtType, ClusterNode evtNode)` Prints the latest topology info into log taking into account logging/verbosity settings.
`void` `addCacheGroup(CacheGroupDescriptor grpDesc, IgnitePredicate<ClusterNode> filter, CacheMode cacheMode)`
`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(@Nullable Collection<UUID> nodeIds)`
`Collection<ClusterNode>` `aliveServerNodes()`
`Collection<ClusterNode>` `allNodes()`
`@Nullable List<? extends BaselineNode>` `baselineNodes(AffinityTopologyVersion topVer)`
`boolean` `cacheAffinityNode(ClusterNode node, String cacheName)` Checks if node is a data node for the given cache.
`boolean` `cacheClientNode(ClusterNode node, String cacheName)`
`boolean` `cacheGroupAffinityNode(ClusterNode node, int grpId)` Checks if node is a data node for the given cache group.
`Collection<ClusterNode>` `cacheGroupAffinityNodes(int grpId, AffinityTopologyVersion topVer)` Gets cache nodes for cache with given ID that participate in affinity calculation.
`boolean` `cacheNearNode(ClusterNode node, String cacheName)`
`boolean` `cacheNode(ClusterNode node, String cacheName)`
`List<ClusterNode>` `cacheNodes(@Nullable String cacheName, AffinityTopologyVersion topVer)` Gets cache nodes for cache with given name.
`void` `cleanCachesAndGroups()`
`void` `clientCacheStartEvent(UUID reqId, @Nullable Map<String,DynamicCacheChangeRequest> startReqs, @Nullable Set<String> cachesToClose)`
`Map<String,Map<UUID,Boolean>>` `clientNodesMap()` Called from discovery thread.
`boolean` `communicationErrorResolveSupported()`
`Serializable` `consistentId()` Deprecated. Use `ClusterNode.consistentId()` of local node to get actual consistent ID.
`Map<UUID,Short>` `consistentId(AffinityTopologyVersion topVer)` Gets consistentId from history for given topology version.
`void` `consistentId(Serializable consistentId)` Sets TCP local node consistent ID.
`DiscoCache` `createDiscoCacheOnCacheChange(AffinityTopologyVersion topVer, DiscoCache discoCache)` Creates discovery cache after `DynamicCacheChangeBatch` received.
`DiscoveryMetricsProvider` `createMetricsProvider()`
`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, @Nullable String warning)`
`@Nullable ClusterNode` `getAlive(UUID nodeId)`
`DiscoverySpi` `getInjectedDiscoverySpi()` Performs injection of discovery SPI if needed, then provides DiscoverySpi SPI.
`long` `gridStartTime()` Gets first grid node start time, see `DiscoverySpi.getGridStartTime()`.
`static void` `initCommunicationErrorResolveConfiguration(IgniteConfiguration cfg)`
`DiscoveryLocalJoinData` `localJoin()`
`DiscoveryEvent` `localJoinEvent()`
`GridFutureAdapter<DiscoveryLocalJoinData>` `localJoinFuture()`
`ClusterNode` `localNode()`
`void` `metricsUpdateEvent(DiscoCache discoCache, ClusterNode node)`
`boolean` `mutableCustomMessages()`
`ClusterNode` `node(AffinityTopologyVersion topVer, UUID id)` Gets node from history for given topology version.
`@Nullable ClusterNode` `node(UUID nodeId)`
`Map<Short,UUID>` `nodeIdMap(AffinityTopologyVersion topVer)` Gets consistentId from history for given topology version.
`Map<String,CacheConfiguration>` `nodePublicCaches(ClusterNode node)`
`Collection<ClusterNode>` `nodes(AffinityTopologyVersion topVer)` Gets all nodes for given topology version.
`Collection<ClusterNode>` `nodes(@Nullable 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.
`@Nullable ClusterNode` `oldestAliveServerNode(AffinityTopologyVersion topVer)`
`void` `onBeforeSpiStart()` This method executed before manager will start SPI.
`boolean` `onClientCacheClose(String cacheName, UUID clientNodeId)` Called from discovery thread.
`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>` `remoteAliveNodesWithCaches(AffinityTopologyVersion topVer)` Gets cache remote nodes for cache with given name.
`Collection<ClusterNode>` `remoteNodes()`
`void` `removeCacheFilter(String cacheName)` Called from discovery thread.
`void` `removeCacheGroup(CacheGroupDescriptor grpDesc)`
`void` `resolveCommunicationError(ClusterNode node, Exception err)`
`void` `sendCustomEvent(DiscoveryCustomMessage msg)`
`List<ClusterNode>` `serverNodes(AffinityTopologyVersion topVer)`
`Collection<ClusterNode>` `serverTopologyNodes(long topVer)` Gets server nodes topology by specified version from snapshots history storage.
`void` `setCacheFilter(int cacheId, int grpId, String cacheName, boolean nearEnabled)` Called from discovery thread.
`<T extends DiscoveryCustomMessage> void` `setCustomEventListener(Class<T> msgCls, CustomEventListener<T> lsnr)`
`int` `size()`
`void` `start()` Starts grid component.
`void` `stop(boolean cancel)` Stops grid component.
`@Nullable 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` `topologyVersion()`
`AffinityTopologyVersion` `topologyVersionEx()`
`boolean` `tryFailNode(UUID nodeId, @Nullable 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, validateNode`

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

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

### Field Detail

#### NODES_SYS_VIEW

    public static final String NODES_SYS_VIEW

See Also:
  Constant Field Values

#### NODES_SYS_VIEW_DESC

    public static final String NODES_SYS_VIEW_DESC

See Also:
  Constant Field Values

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

#### cleanCachesAndGroups

    public void cleanCachesAndGroups()

#### addCacheGroup

    public void addCacheGroup(CacheGroupDescriptor grpDesc,
                              IgnitePredicate<ClusterNode> filter,
                              CacheMode cacheMode)

Parameters:
  `grpDesc` - Cache group descriptor.
  `filter` - Node filter.
  `cacheMode` - Cache mode.

#### removeCacheGroup

    public void removeCacheGroup(CacheGroupDescriptor grpDesc)

Parameters:
  `grpDesc` - Cache group descriptor.

#### setCacheFilter

    public void setCacheFilter(int cacheId,
                               int grpId,
                               String cacheName,
                               boolean nearEnabled)

Called from discovery thread. Adds dynamic cache filter.

Parameters:
  `cacheId` - Cache ID.
  `grpId` - Cache group ID.
  `cacheName` - Cache name.
  `nearEnabled` - Near enabled flag.

#### removeCacheFilter

    public void removeCacheFilter(String cacheName)

Called from discovery thread. 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)

Called from discovery thread. 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()

Called from discovery thread.

Returns:
  Client nodes map.

#### onKernalStart0

    protected void onKernalStart0()
                           throws IgniteCheckedException

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

#### start

    public void start()
               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.

#### createMetricsProvider

    public DiscoveryMetricsProvider createMetricsProvider()

Returns:
  Metrics provider.

#### ackTopology

    public void ackTopology(long topVer,
                            int evtType,
                            ClusterNode evtNode)

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

Parameters:
  `topVer` - Topology version.
  `evtType` - Event type.
  `evtNode` - Event node.

#### 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
                            @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 @Nullable 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 @Nullable ClusterNode node(UUID nodeId)

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

#### nodes

    public Collection<ClusterNode> nodes(@Nullable
                                         @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.

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

#### baselineNodes

    @Nullable
    public @Nullable List<? extends BaselineNode> baselineNodes(AffinityTopologyVersion topVer)

Parameters:
  `topVer` - Topology version.
Returns:
  All baseline nodes for given topology version or `null` if baseline was not set for the 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.

#### consistentId

    public Map<UUID,Short> consistentId(AffinityTopologyVersion topVer)

Gets consistentId from history for given topology version.

Parameters:
  `topVer` - Topology version.
Returns:
  Compacted consistent id.

#### nodeIdMap

    public Map<Short,UUID> nodeIdMap(AffinityTopologyVersion topVer)

Gets consistentId from history for given topology version.

Parameters:
  `topVer` - Topology version.
Returns:
  Compacted consistent id map.

#### cacheNodes

    public List<ClusterNode> cacheNodes(@Nullable
                                        @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.

#### remoteAliveNodesWithCaches

    public Collection<ClusterNode> remoteAliveNodesWithCaches(AffinityTopologyVersion topVer)

Gets cache remote nodes for cache with given name.

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

#### oldestAliveServerNode

    @Nullable
    public @Nullable ClusterNode oldestAliveServerNode(AffinityTopologyVersion topVer)

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

#### cacheGroupAffinityNodes

    public Collection<ClusterNode> cacheGroupAffinityNodes(int grpId,
                                                           AffinityTopologyVersion topVer)

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

Parameters:
  `grpId` - Cache group 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.

#### cacheGroupAffinityNode

    public boolean cacheGroupAffinityNode(ClusterNode node,
                                          int grpId)

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

Parameters:
  `node` - Node to check.
  `grpId` - Cache group ID.
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.

#### nodePublicCaches

    public Map<String,CacheConfiguration> nodePublicCaches(ClusterNode node)

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

#### topology

    @Nullable
    public @Nullable 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.

#### serverTopologyNodes

    public Collection<ClusterNode> serverTopologyNodes(long topVer)

Gets server nodes topology by specified version from snapshots history storage.

Parameters:
  `topVer` - Topology version.
Returns:
  Server topology nodes.

#### daemonNodes

    public Collection<ClusterNode> daemonNodes()

Returns:
  All daemon nodes in topology.

#### localNode

    public ClusterNode localNode()

Returns:
  Local node.

#### consistentId

    @Deprecated
    public Serializable consistentId()

Deprecated. Use `ClusterNode.consistentId()` of local node to get actual consistent ID.

Returns:
  Consistent ID.

#### getInjectedDiscoverySpi

    public DiscoverySpi getInjectedDiscoverySpi()

Performs injection of discovery SPI if needed, then provides DiscoverySpi SPI. Manual injection is required because normal startup of SPI is done after processor started.

Returns:
  Wrapped DiscoverySpi SPI.

#### consistentId

    public void consistentId(Serializable consistentId)

Sets TCP local node consistent ID. This setter is to be called before node init in SPI

Parameters:
  `consistentId` - New value of consistent ID to be used in local node initialization

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

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

#### localJoinFuture

    public GridFutureAdapter<DiscoveryLocalJoinData> localJoinFuture()

Returns:
  Local join future.

#### sendCustomEvent

    public void sendCustomEvent(DiscoveryCustomMessage msg)
                         throws IgniteCheckedException

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

#### clientCacheStartEvent

    public void clientCacheStartEvent(UUID reqId,
                                      @Nullable
                                      @Nullable Map<String,DynamicCacheChangeRequest> startReqs,
                                      @Nullable
                                      @Nullable Set<String> cachesToClose)

Parameters:
  `reqId` - Start request ID.
  `startReqs` - Cache start requests.
  `cachesToClose` - Cache to close.

#### metricsUpdateEvent

    public void metricsUpdateEvent(DiscoCache discoCache,
                                   ClusterNode node)

Parameters:
  `discoCache` -
  `node` -

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

#### initCommunicationErrorResolveConfiguration

    public static void initCommunicationErrorResolveConfiguration(IgniteConfiguration cfg)
                                                           throws IgniteCheckedException

Parameters:
  `cfg` - Configuration.
Throws:
  `IgniteCheckedException` - If configuration is not valid.

#### communicationErrorResolveSupported

    public boolean communicationErrorResolveSupported()

Returns:
  `True` if communication error resolve is supported.

#### mutableCustomMessages

    public boolean mutableCustomMessages()

Returns:
  `True` if configured `DiscoverySpi` supports mutable custom messages.

#### resolveCommunicationError

    public void resolveCommunicationError(ClusterNode node,
                                          Exception err)

Parameters:
  `node` - Problem node.
  `err` - Error.

#### createDiscoCacheOnCacheChange

    public DiscoCache createDiscoCacheOnCacheChange(AffinityTopologyVersion topVer,
                                                    DiscoCache discoCache)

Creates discovery cache after `DynamicCacheChangeBatch` received.

Parameters:
  `topVer` - Topology version.
  `discoCache` - Current disco cache.
Returns:
  New discovery cache.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.8.0
Release Date | : February 27 2020